Getting the http request header in Yesod?

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? Thanks, Rehno

On Sat, Sep 25, 2010 at 10:32 AM, Rehno Lindeque
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...
participants (2)
-
Michael Snoyman
-
Rehno Lindeque