nero-0.3.1: Lens-based HTTP toolkit

Safe HaskellSafe
LanguageHaskell2010

Nero.Request

Contents

Synopsis

Request

data Request Source

An HTTP Request.

Instances

Eq Request Source 
Show Request Source 
Param Request Source

It traverses the values with the same key both in the query string and the form encoded body of a POST Request.

Formed Request Source 
HasBody Request Source 
HasQuery Request Source 
HasPath Request Source 
HasHost Request Source 
HasUrl Request Source 
Server (Request -> Maybe Response) Source 
Server (Request -> Response) Source 

get :: Url -> Request Source

Smart constructor for GET Requests.

post :: Url -> Payload -> Request Source

Smart constructor for POST Requests.

payloaded :: Traversal' Request Payload Source

Traversal' to obtain a Payload from a Request. This is not a Lens' because some Requests, such has GET, are not allowed to have a Payload.

params :: Traversal' Request MultiMap Source

This Traversal lets you traverse every HTTP parameter regardless of whether it's present in the query string or in the form encoded body of a POST Request. In the rare case where there are HTTP parameters in both, every parameter is still being traversed starting from the /query string/.

You might want to use param for traversing a specific parameter.

>>> let request = dummyRequestForm & query . at "name" ?~ ["hello", "out"] & form  . at "name" ?~ ["there"]
>>> foldOf params request ^? ix "name"
Just ["hello","out","there"]

GET

POST

Testing

dummyRequest :: Request Source

An empty GET request useful for testing.

dummyRequestForm :: Request Source

An empty POST request with an empty form encoded body useful for testing.