[web-devel] Add session header to response of Wai.Application.Static.staticApp

Leif Warner abimelech at gmail.com
Mon Feb 17 08:37:32 UTC 2014


I want to add a session cookie header to the response of staticApp.

Now, I know that adding a "session" to a static file doesn't make sense.
I just figured I'd set the session once on the splash page, rather than
risk generating multiple sessions for the subsequently fetched "dynamic"
resources. (They're actually static files, but per-user copies of the
static files.)

I was maybe hoping for something along the lines of:
do
  response <- (staticApp $ defaultWebAppSettings ".") request
  return $ response { responseHeaders = sessionCookie : responseHeaders
response }

But that will tell me "`responseHeaders' is not a record selector".

staticApp returns either ResponseFile, or ResponseBuilder (304 "Not
Modified").  I could import Network.Wai.Internal, pattern match on those,
and return those w/ the added header.

That seems a bit crufty, though - was hoping someone could suggest a more
elegant solution?

Maybe some Lens or Functor instance across a response's headers, I dunno.

-Leif
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/web-devel/attachments/20140217/2d994bee/attachment.html>


More information about the web-devel mailing list