Setting headers using S object from RestHelper

57 views
Skip to first unread message

Stephen Wells

unread,
May 23, 2011, 10:00:27 AM5/23/11
to lif...@googlegroups.com
I'm writing an API using Lift and RestHelper. I need to be able to programmatically set the cache headers on different endpoints depending on the content being returned.

To override the default headers set in Boot.scala I'm calling S.setHeader from within a serveJx partial function. I would expect the served response to have the overridden headers set but the response only has the default headers.

If I implement the endpoint using serve with a partial function that creates a JsonResponse within the partial function the S.setHeader mechanism sets the header as expected.

Should I be able to override the default headers using the S object or is this not supported in RestHelper currently?

I've created a small example RestHelper app (blatently copied from the simply lift example) that demonstrates this and it is available on GitHub at:


The example RestHelper object is at:



Thanks in advance,

    Steve Wells

David Pollak

unread,
May 23, 2011, 11:05:43 AM5/23/11
to lif...@googlegroups.com
In  <= Lift 2.3, the S scope is not available at all in stateless requests.  So, for stateless dispatch you'll have to manually set the headers in the LiftResponse.

I tested the code against Lift 2.4-SNAPSHOT and saw the same issue... but 2.4 is supposed to give you the S scope for stateless dispatch.  This is a defect and I'll address it today.

Thanks for a terrifically detailed and perfectly framed question.  I'm nominating this for Happy Lift'r!

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.



--
Lift, the simply functional web framework http://liftweb.net

David Pollak

unread,
May 23, 2011, 1:17:41 PM5/23/11
to lif...@googlegroups.com
On Mon, May 23, 2011 at 8:05 AM, David Pollak <feeder.of...@gmail.com> wrote:
In  <= Lift 2.3, the S scope is not available at all in stateless requests.  So, for stateless dispatch you'll have to manually set the headers in the LiftResponse.

I tested the code against Lift 2.4-SNAPSHOT and saw the same issue... but 2.4 is supposed to give you the S scope for stateless dispatch.  This is a defect and I'll address it today.

The fix it checked into master and should be available in a SNAPSHOT repository near you in a few hours.
 
Reply all
Reply to author
Forward
0 new messages