[Seaside] Removing HTTP headers

Philippe Marschall philippe.marschall at gmail.com
Mon Jul 10 11:56:52 UTC 2017


On Mon, Jul 10, 2017 at 9:44 AM, David Pennington
<david at totallyobjects.com> 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 & 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 & 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


More information about the seaside mailing list