json package:wai-extra

Wrap json responses in a jsonp callback. Basically, if the user requested a "text/javascript" and supplied a "callback" GET parameter, ask the application for an "application/json" response, then convert that into a JSONP response, having a content type of "text/javascript" and calling the specified callback function.
Automatic wrapping of JSON responses to convert into JSONP.
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.
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.