Is there a way to access cookie headers for a Wai Web App?

232 Views Asked by At

I have a Servant web application. I need to access the cookie headers for debugging purposes. From the browser, I can access the headers including the cookie headers. From the server, I use Wai's RequestLogger to log requests. The results do not show the cookie headers, however.

Is there a way to access the cookie headers in a Wai application?

1

There are 1 best solutions below

0
7puns On BEST ANSWER

I had to use a custom Wai Middleware to log the cookie headers in the requests. Wai Middleware is Application -> Application. The details are presented below in case someone finds it useful.

logRequestHeaders :: Application -> Application
logRequestHeaders incoming request outgoing = do
   let headerList = requestHeaders request
   liftIO $ mapM_ print headerList
   incoming request outgoing