Removing HTTP headers

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Removing HTTP headers

Long Haired David
Hi there.
I am using Seaside in Instantiations VAST Smalltalk to talk to an Android mobile phone app built using Cordova (basically HTML and JavaScript).
I have built a standard REST interface for obtaining and updating data,which is stored in a Riak NoSQL Key/Value database. 
The database data is stored as JSON and the mobile phone Javascript (via JMobile) has a JSON parser.

To make the coding easier and cleaner, I would like to just send the JSON to the app, rather than a"whole" HTML page.
My call is this http://localhost:8080/WSAndroidUser?demo

This responds with:

type="text/javascript">function onLoad(){};</script></body></html>

I would like it just to respond with the JSON.

{"railroadName": "Sunset &amp; North Eastern RR","railroadLogoURL": "http://www.tm470routingproject.co.uk/images/snelogo.png","username": "demo","password": "5F4DCC3B5AA765D61D8327DEB882CF99","currentTTPositionString": "6","maxTTPositionString": "0"}


Can this be done?
David



Message sent using Winmail Mail Server

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
David
Totally Objects
Doing Smalltalk since 1989
Reply | Threaded
Open this post in threaded view
|

Re: Removing HTTP headers

Philippe Marschall
On Mon, Jul 10, 2017 at 9:44 AM, David Pennington
<[hidden email]> wrote:
>
> Hi there.
> I am using Seaside in Instantiations VAST Smalltalk to talk to an Android mobile phone app built using Cordova (basically HTML and JavaScript).
> I have built a standard REST interface for obtaining and updating data,which is stored in a Riak NoSQL Key/Value database.

How have you built this interface? I assume you haven't used
Seaside-REST [1]. It works in theory with VAST but you'll have to use
positional arguments in the path patterns instead of argument names
which is a bit less nice.

> The database data is stored as JSON and the mobile phone Javascript (via JMobile) has a JSON parser.
>
> To make the coding easier and cleaner, I would like to just send the JSON to the app, rather than a"whole" HTML page.
> My call is this http://localhost:8080/WSAndroidUser?demo
>
> This responds with:
>
> type="text/javascript">function onLoad(){};</script></body></html>
>
> I would like it just to respond with the JSON.
>
> {"railroadName": "Sunset &amp; North Eastern RR","railroadLogoURL": "http://www.tm470routingproject.co.uk/images/snelogo.png","username": "demo","password": "5F4DCC3B5AA765D61D8327DEB882CF99","currentTTPositionString": "6","maxTTPositionString": "0"}
>
>
> Can this be done?

There are several ways this can be done all depending on your needs.
In theory at any point during request processing you can just return
JSON with:

self requestContext respond: [ :response |
    response
       contentType: WAMimeType applicationJson;;
        nextPutAll: '{"railroadName": "Sunset &amp; North Eastern RR"}' ]

However doing that in a Seaside application with components doesn't
make a whole lot if sense if it isn't needed for AJAX. So my next step
would be ask for more information about your REST interface. How large
is it? What features do you need?

BTW we also have a canvas API for building JSON WAJsonCanvas ;-)

 [1] https://github.com/SeasideSt/Seaside/wiki/Seaside-REST

Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside