Nodetrout.Internal.Request
- Package
- purescript-nodetrout
- Repository
- nsaunders/purescript-nodetrout
This module contains various request-processing functionality that would
otherwise clutter the Router
module and increase its coupling to the Node
server (bad for testability).
#Request Source
newtype Request
A Request
contains the request method, URL, and headers, as well as an
Aff
that reads the request body, which are used in the routing logic.
Since this library is only interested in building a Node server, this
abstraction really only exists to help test routing logic.
Constructors
Request { headers :: Object String, method :: String, stringBody :: Aff (Maybe String), url :: String }
Instances
#headerValue Source
headerValue :: String -> Request -> Maybe String
Attempts to get the value from a request header.
#queryParamValue Source
queryParamValue :: String -> Request -> Maybe String
Gets the first value from the query string matching the specified label
(key). For example, given a label of foo
and a request with a query string
of ?foo=bar&foo=baz
, this would return a string "bar"
.
#queryParamValues Source
queryParamValues :: String -> Request -> Array String
Gets all values from the query string matching the specified label (key).
For example, given a label of foo
and a request with a query string of
?foo=bar&foo=baz
, this would return an array ["bar", "baz"]
.