wai-extra-3.1.14: Provides some basic WAI handlers and middleware.

Safe Haskell | None
Language | Haskell2010

Network.Wai.Middleware.RequestLogger.JSON

Synopsis

- formatAsJSON :: OutputFormatterWithDetails
- formatAsJSONWithHeaders :: OutputFormatterWithDetailsAndHeaders
- requestToJSON :: Request -> [ByteString] -> Maybe NominalDiffTime -> Value

# Documentation

formatAsJSON :: OutputFormatterWithDetails #

formatAsJSONWithHeaders :: OutputFormatterWithDetailsAndHeaders #

Same as `formatAsJSON` but with response headers included

This is useful for passing arbitrary data from your application out to the WAI layer for it to be logged, but you may need to be careful to subsequently redact any headers which may contain sensitive data.

Since: 3.0.27

requestToJSON #

Arguments

:: Request | The WAI request
-> [ByteString] | Chunked request body
-> Maybe NominalDiffTime | Optional request duration
-> Value |

Get the JSON representation for a request

This representation is identical to that used in `formatAsJSON` for the request. It includes:

`method`
`path`
`queryString`
`size`
  The size of the body, as defined in the request. This may differ from the size of the data passed in the second argument.
`body`
  The body, concatenated directly from the chunks passed in
`remoteHost`
`httpVersion`
`headers`

If a ``Just` duration` is passed in, then additionally the JSON includes:

`durationMs`
  The duration, formatted in milliseconds, to 2 decimal places

This representation is not an API, and may change at any time (within reason) without a major version bump.

Since: 3.1.4