On Wed, 04 Nov 2015 06:58:53 GMT, Brad Anderson wrote:

There was some talk about this on the forums before but I didn't really see an answer.

I can't use SessionVar (it only works with the web interface) and the REST interface generator doesn't seem to allow using HTTPServerRequest/Response parameters like the web interface generator does so I can't access a session that way. I saw some stuff about using @before but I don't understand how that would help (@before doesn't appear to be documented that I can see).

The REST interface generator is generally designed to enforce the RESTful aspects of the interface as far as possible. Since REST requests are supposed to be state-less, sessions are not directly supported.

However, you could (ab)use the @before attribute to get the desired effect:

class RestIntf {
    @before!getSession("session")
    void test(Session session)
    {
    }
}

Session getSession(HTTPServerRequest req, HTTPServerResponse res)
{
    return req.session ? req.session : res.startSession();
}

But this sounds like we should put some effort into fully supporting JSON based routes in the web interface generator. Return values of type Json are already supported, but not much more than that.