talira

http-media

Haskell library for parsing and matching HTTP Accept and Content-Type headers

open sourceMITfree

http-media is a Haskell library for parsing quality-indexed values in HTTP headers and choosing among them. It parses media types and language parameters from the Accept and Content header families, then matches a list of the server's options against the client's quality values: mapAcceptMedia picks what to send for an Accept header, and mapContentMedia picks a request body parser for a Content-Type. It can be extended to other Accept headers, and it works with any web server.

Problems it solves

  • content negotiation on the Accept header in a Haskell web app
  • pick a request body parser from the Content-Type in Haskell
  • serve JSON or HTML depending on what the client asks for

Features

  • parses media types and languages from Accept and Content headers
  • matches server options against the client's quality values
  • extensible to other Accept headers
  • agnostic to the web server