Network.HTTP.Types.Exchange
- Package
- purescript-http-types
- Repository
- chrisdotcode/purescript-http-types
#defURI Source
defURI :: URI
A 'default' base url useful for constructing requests. Equivalent to http://localhost:80/.
#defRequest Source
defRequest :: { auth :: Maybe Auth, body :: String, cookies :: List Cookie, headers :: Headers, method :: Method, timeout :: Maybe Milliseconds, uri :: URI }
A 'default' record useful for constructing requests. Equivalent to a request that is sent to http://localhost:80/ with the GET method, no headers, cookies, authentication, body or timeout.
#defRequest' Source
defRequest' :: Request
A 'default' request useful for constructing requests. It wraps the 'defRequest' record with the 'Request' constructor.
#makeQuery' Source
makeQuery' :: String -> Query
Constructs a query string from a single string (e.g.: makeQuery' hungry
==
?hungry
).
#modifyPath Source
modifyPath :: (URIPathAbs -> URIPathAbs) -> Request -> Request
#setTimeout Source
setTimeout :: Milliseconds -> Request -> Request
#uriToRequest' Source
uriToRequest' :: URI -> Request
Constructs a 'Request' from a 'URI'. The request has all of the values of 'defRequest', with the URI set to the passed parameter.
#uriToRequest Source
uriToRequest :: forall m. MonadError Error m => String -> m Request
Constructs a 'Request' from a uri string. The request has all of the values of 'defRequest', with the URI set to the passed parameter. If the uri string could not be parsed, the parsing error is thrown.
#uriToRequest'' Source
uriToRequest'' :: String -> Maybe Request
Constructs a 'Request' from a uri string. The request has all of the
values of 'defRequest', with the URI set to the passed parameter. If the
uri string could not be parsed, Nothing
is returned.
#get Source
get :: forall m. MonadError Error m => String -> m Request
Constructs a 'Request' from a uri string. The request has all of the
values of 'defRequest', with the URI set to the passed parameter, and the
method set to GET
. If the uri string could not be parsed, the parsing
error is thrown.
#post Source
post :: forall m. MonadError Error m => String -> m Request
Constructs a 'Request' from a uri string. The request has all of the
values of 'defRequest', with the URI set to the passed parameter, and the
method set to POST
. If the uri string could not be parsed, the parsing
error is thrown.
#postWithBody Source
postWithBody :: forall m. MonadError Error m => String -> String -> m Request
Constructs a 'Request' from a uri string. The request has all of the
values of 'defRequest', with the URI set to the passed uri, the method set
to POST
, and the request body equal to passed body. If the uri string
could not be parsed, the parsing error is thrown.
#put Source
put :: forall m. MonadError Error m => String -> m Request
Constructs a 'Request' from a uri string. The request has all of the
values of 'defRequest', with the URI set to the passed parameter, and the
method set to PUT
. If the uri string could not be parsed, the parsing
error is thrown.
#putWithBody Source
putWithBody :: forall m. MonadError Error m => String -> String -> m Request
Constructs a 'Request' from a uri string. The request has all of the
values of 'defRequest', with the URI set to the passed uri, the method set
to PUT
, and the request body equal to passed body. If the uri string
could not be parsed, the parsing error is thrown.
#patch Source
patch :: forall m. MonadError Error m => String -> m Request
Constructs a 'Request' from a uri string. The request has all of the
values of 'defRequest', with the URI set to the passed parameter, and the
method set to PATCH
. If the uri string could not be parsed, the parsing
error is thrown.
#patchWithBody Source
patchWithBody :: forall m. MonadError Error m => String -> String -> m Request
Constructs a 'Request' from a uri string. The request has all of the
values of 'defRequest', with the URI set to the passed uri, the method set
to PATCH
, and the request body equal to passed body. If the uri string
could not be parsed, the parsing error is thrown.
#delete Source
delete :: forall m. MonadError Error m => String -> m Request
Constructs a 'Request' from a uri string. The request has all of the
values of 'defRequest', with the URI set to the passed parameter, and the
method set to DELETE
. If the uri string could not be parsed, the parsing
error is thrown.
#setResponseStatusCode Source
setResponseStatusCode :: StatusCode -> Response -> Response
#fromJSONWith Source
fromJSONWith :: forall e a m. MonadError Error m => Show e => (String -> Either e a) -> Response -> m a
Takes a completed 'Response', extracts its string body, and converts that to our desired type using the given function. Throws an error if the conversion fails.
The given function is expected to take the string body, and return a Show
errmsg => Left errmsg
if the conversion fails, or a Right a
if the
conversion is successful.