
On Sun, Sep 26, 2010 at 2:04 AM, Rehno Lindeque
Thank you, that sounds exactly like what I need. I didn't notice it before!
Rehno
On Sat, Sep 25, 2010 at 6:57 PM, Michael Snoyman
wrote: On Sat, Sep 25, 2010 at 10:32 AM, Rehno Lindeque
wrote: I'm looking to detect ajax requests sent to my yesod application using the technique detailed in http://davidwalsh.name/detect-ajax
Is it possible to gain access to the request header directly or would yesod require modification to get at it? If someone could just point me in the right direction, I would be grateful. I imagine it would be a function returning GHandler?
You can use waiRequest[1] to get access to the WAI request value, and requestHeaders[2] to get the request headers from it. It's very convenient to use the OverloadedStrings extensions when dealing with the CIByteString datatype[3].
Hope that helps, Michael
[1] http://hackage.haskell.org/packages/archive/yesod/0.5.0.3/doc/html/Yesod-Req... [2] http://hackage.haskell.org/packages/archive/wai/0.2.0/doc/html/Network-Wai.h... [3] http://hackage.haskell.org/packages/archive/wai/0.2.0/doc/html/Network-Wai.h...
Thanks a lot, this was very helpful! One more question. Is it possible to manipulate the request header when doing a redirect? For example, at one I have (redirect RedirectTemporary $ AuthR LoginR), but "X-Requested-With" isn't being passed through...