nero-0.1.1: Lens-based HTTP toolkit

Safe HaskellSafe-Inferred
LanguageHaskell2010

Nero.Request

Contents

Synopsis

Documentation

data Request Source

An HTTP Request.

Instances

Eq Request 
Show Request 
Param Request

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

HasQuery Request 
HasPath Request 
HasHost Request 
HasUrl Request 
Formed Request 
Payloaded Request 

_GET :: Prism' Request Request Source

Prism' to filter GET Requests.

>>> dummyRequest ^? _GET <&> method
Just "GET"
>>> dummyRequestForm ^? _GET <&> method
Nothing

_POST :: Prism' Request Request Source

Prism' to filter for POST Requests.

>>> dummyRequest ^? _POST <&> method
Nothing
>>> dummyRequestForm ^? _POST <&> method
Just "POST"

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"]

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.