Safe Haskell | None |
---|---|
Language | Haskell2010 |
HTTP utilities for server (WAI) and client
Synopsis
- httpContentTypeJSON :: Header
- httpRequestPath :: Request -> Text
- httpRequestBodyText :: Request -> IO Text
- httpRequestBodyJSON :: forall a. FromJSON a => Request -> IO a
- httpRequestHeaders :: Request -> Vector (Text, Text)
- httpRequestHeadersMap :: Request -> HashMap Text Text
- httpResponseBody :: Text -> Response BodyReader -> Int -> IO ByteString
- httpResponseBodyText :: Text -> Response BodyReader -> Int -> IO Text
- httpResponseBodyJSON :: forall a. FromJSON a => Text -> Response BodyReader -> Int -> IO a
- httpResponseHeaders :: Response a -> Vector (Text, Text)
- httpResponseHeadersMap :: Response a -> HashMap Text Text
Documentation
httpContentTypeJSON :: Header Source #
Content-Type
header for application/json
type
httpRequestPath :: Request -> Text Source #
URL path string of the specified HTTP request
Arguments:
req :: Request
: HTTP request
Return value: URL path string
httpRequestBodyText :: Request -> IO Text Source #
Reads a body of the specified HTTP request as a Text
string
Arguments:
req :: Request
: HTTP request
Return value: Request body as a Text
string
httpRequestBodyJSON :: forall a. FromJSON a => Request -> IO a Source #
Reads a body of the specified HTTP request and parses it as a JSON value
Data type should be specified with a type annotation:
Example:
dt <- httpRequestBodyJSON req :: IO Foo
Data must be an instance of FromJSON
Arguments:
req :: Request
: HTTP request
Return value: Request body parsed as a JSON value
httpRequestHeaders :: Request -> Vector (Text, Text) Source #
Headers of the specified HTTP request as a Vector
of (name, value)
pairs
Arguments:
req :: Request
: HTTP request
Return value: Request headers as a Vector
of (name, value)
pairs
httpRequestHeadersMap :: Request -> HashMap Text Text Source #
Headers of the specified HTTP request as a name -> value
map
Arguments:
req :: Request
: HTTP request
Return value: Request headers as a name -> value
map
httpResponseBody :: Text -> Response BodyReader -> Int -> IO ByteString Source #
Read a body of HTTP response as a lazy ByteString
Arguments:
label :: Text
: Label used for error reporting on overly-large responsesresp :: Response BodyReader
: HTTP responsethreshold :: Int
Max response body length in bytes
Return value: Response body as a lazy ByteString
httpResponseBodyText :: Text -> Response BodyReader -> Int -> IO Text Source #
Read a body of HTTP response as a Text
string
Arguments:
label :: Text
: Label used for error reporting on overly-large responsesresp :: Response BodyReader
: HTTP responsethreshold :: Int
Max response body length in bytes
Return value: Response body as a Text
string
httpResponseBodyJSON :: forall a. FromJSON a => Text -> Response BodyReader -> Int -> IO a Source #
Read a body of HTTP response as a JSON value
Data type should be specified with a type annotation:
Example:
dt <- httpResponseBodyJSON label resp 1024 :: IO Foo
Data must be an instance of FromJSON
Arguments:
label :: Text
: Label used for error reporting on overly-large responsesresp :: Response BodyReader
: HTTP responsethreshold :: Int
Max response body length in bytes
Return value: Response body as a JSON value