Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Network.HTTP.Barf
Description
Barf
is a http client library that tries to make scripting http requests as easy as possible.
It provides a monoidal combinator library that should not clash with Prelude
imports.
It delegates to and includes for convenience the great aeson library for e.g. decoding of json
Example Usage:
>>>
:set -XOverloadedLists
>>>
decode @Value <$> get_ "https://jsonplaceholder.typicode.com/posts" [q_ "userId" "1"]
Just (Array [Object (fromList [("body",String ...
Synopsis
- get_ :: MonadIO m => String -> Req -> m LazyByteString
- head_ :: MonadIO m => String -> Req -> m LazyByteString
- post_ :: MonadIO m => String -> Req -> m LazyByteString
- put_ :: MonadIO m => String -> Req -> m LazyByteString
- delete_ :: MonadIO m => String -> Req -> m LazyByteString
- data Req
- q_ :: String -> String -> Req
- h_ :: String -> String -> Req
- j_ :: ToJSON a => a -> Req
- v_ :: Value -> Req
- inspectRequest_ :: Req
- dryRun_ :: Req
- module Data.Aeson
prepare a request
Arguments
:: MonadIO m | |
=> String | the url to connect to |
-> Req | the modifier(s) to the request |
-> m LazyByteString |
creates a GET
request, use it like
get_
"http://localhost:8080" []
Arguments
:: MonadIO m | |
=> String | the url to connect to |
-> Req | the modifier(s) to the request |
-> m LazyByteString |
creates a HEAD
request, use it like
head_
"http://localhost:8080" []
Arguments
:: MonadIO m | |
=> String | the url to connect to |
-> Req | the modifier(s) to the request |
-> m LazyByteString |
creates a POST
request, use it like
post_
"http://localhost:8080" []
Arguments
:: MonadIO m | |
=> String | the url to connect to |
-> Req | the modifier(s) to the request |
-> m LazyByteString |
creates a PUT
request, use it like
put_
"http://localhost:8080" []
Arguments
:: MonadIO m | |
=> String | the url to connect to |
-> Req | the modifier(s) to the request |
-> m LazyByteString |
creates a DELETE
request, use it like
delete_
"http://localhost:8080" []
modify an http request
the type of http request modifications
The type of request modifications.
The most important features of this type are the Monoid
, Semigroup
and IsList
instances.
Instances
Monoid Req Source # | the empty |
Semigroup Req Source # | combining to |
IsList Req Source # | An Even though |
type Item Req Source # | |
Defined in Network.HTTP.Barf.Internal |
http request modifiers
q_
like "query"
h_
like "header"
j_
like "json"
if the json body is already set, it will be overwritten
debugging helpers
inspectRequest_ :: Req Source #
print the request before dispatching, useful for debugging
useful reexports
module Data.Aeson