name: http-media version: 0.5.0 x-revision: 1 license: MIT license-file: LICENSE author: Timothy Jones maintainer: Timothy Jones homepage: https://github.com/zmthy/http-media bug-reports: https://github.com/zmthy/http-media/issues copyright: (c) 2012-2015 Timothy Jones category: Web build-type: Simple cabal-version: >= 1.10 synopsis: Processing HTTP Content-Type and Accept headers description: This library is intended to be a comprehensive solution to parsing and selecting quality-indexed values in HTTP headers. It is capable of parsing both media types and language parameters from the Accept and Content header families, and can be extended to match against other accept headers as well. Selecting the appropriate header value is achieved by comparing a list of server options against the quality-indexed values supplied by the client. . In the following example, the Accept header is parsed and then matched against a list of server options to serve the appropriate media using 'mapAcceptMedia': . > getHeader >>= maybe send406Error sendResourceWith . mapAcceptMedia > [ ("text/html", asHtml) > , ("application/json", asJson) > ] . Similarly, the Content-Type header can be used to produce a parser for request bodies based on the given content type with 'mapContentMedia': . > getContentType >>= maybe send415Error readRequestBodyWith . mapContentMedia > [ ("application/json", parseJson) > , ("text/plain", parseText) > ] . The API is agnostic to your choice of server. library hs-source-dirs: src ghc-options: -Wall default-language: Haskell2010 default-extensions: OverloadedStrings exposed-modules: Network.HTTP.Media Network.HTTP.Media.Accept Network.HTTP.Media.Language Network.HTTP.Media.MediaType Network.HTTP.Media.RenderHeader other-modules: Network.HTTP.Media.Language.Internal Network.HTTP.Media.MediaType.Internal Network.HTTP.Media.Quality Network.HTTP.Media.Utils build-depends: base >= 4.6 && < 4.8, bytestring >= 0.10 && < 0.11, case-insensitive >= 1.0 && < 1.3, containers >= 0.5 && < 0.6 test-suite test-http-media type: detailed-0.9 hs-source-dirs: src test default-language: Haskell2010 default-extensions: OverloadedStrings test-module: Tests other-modules: Network.HTTP.Media Network.HTTP.Media.Accept Network.HTTP.Media.Accept.Tests Network.HTTP.Media.Gen Network.HTTP.Media.Language Network.HTTP.Media.Language.Gen Network.HTTP.Media.Language.Internal Network.HTTP.Media.Language.Tests Network.HTTP.Media.MediaType Network.HTTP.Media.MediaType.Gen Network.HTTP.Media.MediaType.Internal Network.HTTP.Media.MediaType.Tests Network.HTTP.Media.Quality Network.HTTP.Media.RenderHeader Network.HTTP.Media.Tests Network.HTTP.Media.Utils ghc-options: -Wall -Werror build-depends: base >= 4.6 && < 5.0, bytestring >= 0.10 && < 0.11, Cabal >= 1.19 && < 1.23, cabal-test-quickcheck >= 0.1 && < 0.2, case-insensitive >= 1.0 && < 1.3, containers >= 0.5 && < 0.6, QuickCheck >= 2.6 && < 2.9 source-repository head type: git location: git://github.com/zmthy/http-media.git