Search code examples
haskellhttp-headersservant

Servant: see all request headers


I know from the documentation that I can do something like the following to capture a specific header:

type MyApi = "view-my-referer" :> Header "from" Referer :> Get '[JSON] Referer

But I'm exploring some webhooks that aren't well documented, and I'd like to just inspect all the headers in the request.


Solution

  • I use Network.Wai.Middleware.RequestLogger to log headers for all incoming requests, regardless of which Servant endpoint ends up handling the request. I've used this to understand under-documented APIs, and for other sorts of debugging.