-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Specification of HTTP request/response generators and parsers -- -- 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 ] @package httpspec @version 0.3.0.1 module Data.HttpSpec.Pretty class Pretty a ppr :: (Pretty a) => a -> Doc pprString :: (Pretty a) => a -> String module Data.HttpSpec.EncodingHelper encodingName :: (Show enc) => enc -> String xmlEncoding :: (Monad m) => ByteString -> m DynEncoding encodingFromContentType :: String -> Maybe DynEncoding module Data.HttpSpec.HttpTypes type HttpBody = ByteString type HttpMethod = RequestMethod type HttpUrl = URI type HttpCode = Int type HttpReason = String type HttpHeaderName = HeaderName type HttpHeaderValue = String type HttpHeader = (HttpHeaderName, String) type HttpHeaders = [HttpHeader] type HttpParamName = String type HttpParamValue = String type HttpParams = [(HttpParamName, HttpParamValue)] data HttpData HttpData :: HttpHeaders -> HttpBody -> HttpData http_headers :: HttpData -> HttpHeaders http_body :: HttpData -> HttpBody data ReqIn ReqIn :: HttpUrl -> HttpUrl -> HttpMethod -> HttpData -> ReqIn reqIn_progUrl :: ReqIn -> HttpUrl reqIn_fullUrl :: ReqIn -> HttpUrl reqIn_method :: ReqIn -> HttpMethod reqIn_data :: ReqIn -> HttpData data ReqOut ReqOut :: HttpUrl -> HttpMethod -> HttpData -> ReqOut reqOut_url :: ReqOut -> HttpUrl reqOut_method :: ReqOut -> HttpMethod reqOut_data :: ReqOut -> HttpData data ResIn ResIn :: HttpCode -> HttpReason -> HttpData -> ResIn resIn_code :: ResIn -> HttpCode resIn_reason :: ResIn -> HttpReason resIn_data :: ResIn -> HttpData data ResOut ResOut :: HttpCode -> Maybe HttpReason -> HttpData -> ResOut resOut_code :: ResOut -> HttpCode resOut_reason :: ResOut -> Maybe HttpReason resOut_data :: ResOut -> HttpData class IsHttp a httpData :: (IsHttp a) => a -> HttpData httpSetData :: (IsHttp a) => a -> HttpData -> a httpHeaders :: (IsHttp a) => a -> HttpHeaders httpBody :: (IsHttp a) => a -> HttpBody httpGetHeader :: (IsHttp a) => HttpHeaderName -> a -> Maybe HttpHeaderValue httpHasHeader :: (IsHttp a) => HttpHeaderName -> a -> Bool httpSetBody :: (IsHttp a) => HttpBody -> a -> a httpSetHeaders :: (IsHttp a) => HttpHeaders -> a -> a httpSetHeader :: (IsHttp a) => HttpHeaderName -> HttpHeaderValue -> a -> a class (IsHttp a) => IsReq a reqMethod :: (IsReq a) => a -> HttpMethod reqUrl :: (IsReq a) => a -> HttpUrl reqSetMethod :: (IsReq a) => HttpMethod -> a -> a reqSetUrl :: (IsReq a) => HttpUrl -> a -> a reqUrlPath :: (IsReq a) => a -> HttpPath reqSetUrlPath :: (IsReq a) => HttpPath -> a -> a reqAppendUrlPath :: (IsReq a) => HttpPath -> a -> a reqAddUrlParam :: (IsReq a) => HttpParamName -> HttpParamValue -> a -> a class (IsHttp a) => IsRes a resCode :: (IsRes a) => a -> HttpCode resSetStatus :: (IsRes a) => HttpCode -> Maybe HttpReason -> a -> a resReason :: (IsRes a) => a -> HttpReason reqIn_body :: ReqIn -> HttpBody reqIn_headers :: ReqIn -> HttpHeaders reqOut_body :: ReqOut -> HttpBody reqOut_headers :: ReqOut -> HttpHeaders resIn_body :: ResIn -> HttpBody resIn_headers :: ResIn -> HttpHeaders resOut_body :: ResOut -> HttpBody resOut_headers :: ResOut -> HttpHeaders urlParams :: HttpUrl -> HttpParams urlMatchPrefix :: HttpPath -> HttpUrl -> Maybe HttpUrl urlMatchPrefix' :: HttpUrl -> HttpUrl -> Maybe HttpUrl urlSplit :: (Monad m) => HttpUrl -> m (HttpPath, HttpUrl) url :: String -> HttpUrl completeReq :: (IsHttp req) => req -> req completeRes :: (IsHttp res) => res -> res mkHeaderName :: String -> HttpHeaderName instance Show ResOut instance Show ResIn instance Show ReqOut instance Show ReqIn instance Show HttpData instance Pretty RequestMethod instance Pretty ResOut instance Pretty ResIn instance Pretty ReqOut instance Pretty ReqIn instance Pretty HttpData instance Pretty URI instance IsReq ReqOut instance IsReq ReqIn instance IsRes ResOut instance IsRes ResIn instance IsHttp ResOut instance IsHttp ResIn instance IsHttp ReqOut instance IsHttp ReqIn instance IsHttp HttpData instance Ord HeaderName module Data.HttpSpec type ReqSpec = Spec ReqErr ReqIn ReqOut type ResSpec = Spec ResErr ResIn ResOut type HttpSpec = Spec HttpErr data WebComm WebCommIn :: WebIn -> WebComm WebCommOut :: WebOut -> WebComm data WebIn WebIn :: Maybe ReqIn -> Maybe ResOut -> WebIn webIn_req :: WebIn -> Maybe ReqIn webIn_res :: WebIn -> Maybe ResOut data WebOut WebOut :: Maybe ReqOut -> Maybe ResIn -> WebOut webOut_req :: WebOut -> Maybe ReqOut webOut_res :: WebOut -> Maybe ResIn data WebExc WebExc :: Maybe WebComm -> WebErr -> WebExc webExc_comm :: WebExc -> Maybe WebComm webExc_err :: WebExc -> WebErr data WebErr WebErrMissingParam :: String -> WebErr WebErrMissingHeader :: HttpHeaderName -> WebErr WebErrInvalidHeaderValue :: HttpHeaderName -> HttpHeaderValue -> String -> WebErr WebErrInvalidMethod :: HttpMethod -> String -> WebErr WebErrInvalidStatus :: Int -> String -> WebErr WebErrInvalidUrl :: String -> String -> WebErr WebErrMissingContentType :: WebErr WebErrUnexpectedContentType :: String -> String -> WebErr WebErrEmptyContent :: WebErr WebErrNoMatch :: ReqIn -> WebErr WebErrNotImplemented :: String -> WebErr WebErrCustomMsg :: String -> WebErr class HasReqSpec a reqSpec :: (HasReqSpec a) => ReqSpec a class HasResSpec a resSpec :: (HasResSpec a) => ResSpec a type TextEncoding = DynEncoding rsHeader :: (IsHttp i, IsHttp o) => HttpHeaderName -> HttpSpec i o HttpHeaderValue rsHeaderFixed :: (IsHttp i, IsHttp o) => HttpHeader -> HttpSpec i o a -> HttpSpec i o a rsParam :: HttpParamName -> ReqSpec HttpParamValue rsMeth :: HttpMethod -> ReqSpec a -> ReqSpec a rsStatus :: Int -> ResSpec a -> ResSpec a rsXmlString :: (Error e) => PU a -> Spec e i o String -> Spec e i o a rsXml :: (Error e) => XmlEncoding -> PU a -> Spec e i o ByteString -> Spec e i o a rsValidXml :: (Error e) => XmlEncoding -> XmlValidator -> PU a -> Spec e i o ByteString -> Spec e i o a rsPath :: ReqSpec String rsPathFixed :: String -> ReqSpec a -> ReqSpec a rsWithBody :: (IsHttp i, IsHttp o) => (HttpSpec i o ByteString -> HttpSpec i o a) -> HttpSpec i o a rsBody :: (IsHttp i, IsHttp o) => HttpSpec i o ByteString rsContentType :: (IsHttp i, IsHttp o) => String -> HttpSpec i o a -> HttpSpec i o a rsPathSegment :: ReqSpec a -> ReqSpec (String, a) rsXmlEncoding :: (Error e) => Spec e i o String -> Spec e i o XmlEncoding rsTextEncoding :: (Error e) => Spec e i o String -> Spec e i o TextEncoding rsEncodingFixed :: (Error e, Encoding enc) => enc -> Spec e i o ByteString -> Spec e i o String genReqOut :: (Monad m) => ReqSpec a -> HttpUrl -> a -> m ReqOut genResOut :: (Monad m) => ResSpec a -> a -> m ResOut parseReqIn :: (MonadError ReqErr m) => ReqSpec a -> ReqIn -> m a parseResIn :: (MonadError ReqErr m) => ResSpec a -> ResIn -> m a rsXmlBody :: (IsHttp i, IsHttp o) => PU a -> HttpSpec i o a webExcSetReqIn :: ReqIn -> WebExc -> WebExc webExcSetResIn :: ResIn -> WebExc -> WebExc webExcSetReqOut :: ReqOut -> WebExc -> WebExc webExcSetResOut :: ResOut -> WebExc -> WebExc instance Show WebErr instance Show WebExc instance Show WebOut instance Show WebIn instance Show WebComm instance Pretty WebErr instance Pretty WebExc instance Error WebExc instance Error WebErr