Copyright | (c) 2016 Owain Lewis |
---|---|
License | BSD-style |
Maintainer | owain@owainlewis.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
HTTP request generation DSL
- data HTTPRequest = HTTPRequest {
- reqMethod :: HTTPRequestMethod
- reqUrl :: String
- reqHeaders :: [Header]
- reqBody :: Maybe ByteString
- data HTTPResponse = HTTPResponse {
- respStatus :: Int
- respHeaders :: [Header]
- respBody :: ByteString
- data HTTPRequestMethod
- runRequest :: Runnable a => a -> IO HTTPResponse
- rawRequest :: HTTPRequestMethod -> String -> [Header] -> Maybe ByteString -> HTTPRequest
- getRequest :: String -> [Header] -> HTTPRequest
- postRequest :: Url -> Headers -> Maybe ByteString -> HTTPRequest
- putRequest :: Url -> Headers -> Maybe ByteString -> HTTPRequest
- patchRequest :: Url -> Headers -> Maybe ByteString -> HTTPRequest
- deleteRequest :: Url -> Headers -> HTTPRequest
- headRequest :: Url -> [Header] -> HTTPRequest
- optionsRequest :: Url -> [Header] -> HTTPRequest
- withQueryParams :: HTTPRequest -> [(String, String)] -> HTTPRequest
Documentation
data HTTPRequest Source #
HTTPRequest | |
|
data HTTPResponse Source #
HTTPResponse | |
|
data HTTPRequestMethod Source #
runRequest :: Runnable a => a -> IO HTTPResponse Source #
rawRequest :: HTTPRequestMethod -> String -> [Header] -> Maybe ByteString -> HTTPRequest Source #
Make a raw HTTP request
raw GET "http://google.com" [header Content-Type "application/json"] Nothing HTTPRequest { reqMethod = GET , reqUrl = "http://google.com" , reqHeaders = [(Content-Type,"application/json")] , reqBody = Nothing }
getRequest :: String -> [Header] -> HTTPRequest Source #
Make a simple HTTP GET request with headers
getRequest "http://google.com" [header Content-Type "application/json"] HTTPRequest { reqMethod = GET , reqUrl = "http://google.com" , reqHeaders = [(Content-Type,"application/json")] , reqBody = Nothing }
postRequest :: Url -> Headers -> Maybe ByteString -> HTTPRequest Source #
Make a HTTP POST request with headers
putRequest :: Url -> Headers -> Maybe ByteString -> HTTPRequest Source #
Make a HTTP PUT request with headers
patchRequest :: Url -> Headers -> Maybe ByteString -> HTTPRequest Source #
Make a HTTP PATCH request with headers
deleteRequest :: Url -> Headers -> HTTPRequest Source #
Make a HTTP DELETE request with headers
headRequest :: Url -> [Header] -> HTTPRequest Source #
Make a HTTP HEAD request
optionsRequest :: Url -> [Header] -> HTTPRequest Source #
Make a HTTP OPTIONS request
withQueryParams :: HTTPRequest -> [(String, String)] -> HTTPRequest Source #
Add query params to a request URL
withQueryParams (get "http://google.com") [("foo", "bar")] HTTPRequest { reqMethod = GET , reqUrl = "http://google.com?foo=bar" , reqHeaders = [] , reqBody = Nothing }