The httpspec package

[ Tags: data, lgpl, library, web ] [ Propose Tags ]

Using httpspec you can write a specification for a HTTP request/response defining the method, headers, url parameters and the body. This specification bidirectionally maps an abstract request/response data type to a concrete realisation as a HTTP request/response. The specification can be used to generate HTTP requests/responses from an abstract description and it can be used to parse a HTTP request/response into such an abstract description. The idea is very similar to the way pickling of XML data is described in HXT. For example, the abstract representation of an authentication request and response could be described as data AuthUserReq = AuthUserReq authUser_user :: String , authUser_pass :: String data AuthUserRes = AuthUserOk authUserOk_sid :: String | AuthUserFailed Using httpspec you can define a mapping between HTTP and these types: instance HasReqSpec AuthUserReq where reqSpec = rsMeth Http.POST $ rsPath "/authenticate-user" $ rsWrap (uncurry AuthUserReq, (AuthUserReq a b) -> (a,b)) $ rsPair (rsParam "uid") (rsParam "pass") instance HasResSpec AuthUserRes where resSpec = rsSwitch [ rsCase (AuthUserOk,authUserOk_sid) $ rsStatus 200 $ rsContentType "text/plain" $ rsEncodingFixed UTF8 $ rsBody , rsCaseConst AuthUserFailed $ rsStatus 403 ]


Versions 0.1,
Dependencies base (==4.*), bidispec, bytestring, cgi, containers, encoding (>=0.6), filepath, HTTP, hxt (>8.3 && <8.4), mtl, network, pretty, Safe, tagsoup (==0.6) [details]
License LGPL
Author David Leuschner
Maintainer David Leuschner <>
Category Data, Web
Uploaded Sun Mar 21 10:41:51 UTC 2010 by DavidLeuschner
Distributions NixOS:
Downloads 811 total (6 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]
Hackage Matrix CI




Maintainer's Corner

For package maintainers and hackage trustees