Skip to content

Latest commit

 

History

History
249 lines (160 loc) · 5.23 KB

File metadata and controls

249 lines (160 loc) · 5.23 KB

Module Node.Express.Request

getRouteParam

getRouteParam :: forall e a. RequestParam a => a -> HandlerM (express :: EXPRESS | e) (Maybe String)

Get route param value. If it is named route, e.g /user/:id then getRouteParam "id" return matched part of route. If it is regex route, e.g. /user/(\d+) then getRouteParam 1 return part that matched (\d+) and getRouteParam 0 return whole route.

getQueryParam

getQueryParam :: forall e. String -> HandlerM (express :: EXPRESS | e) (Maybe String)

Get param from query string (part of URL behind '?'). If there are multiple params having equal keys return the first one.

getQueryParams

getQueryParams :: forall e. String -> HandlerM (express :: EXPRESS | e) (Array String)

Get all params from query string having specified key.

getBody

getBody :: forall e a. Decode a => HandlerM (express :: EXPRESS | e) (Either MultipleErrors a)

Get the request's body. NOTE: Not parsed by default, you must attach proper middleware See http://expressjs.com/4x/api.html#req.body

getBody'

getBody' :: forall e. HandlerM (express :: EXPRESS | e) Foreign

Get the request's body without a Decode parsing. NOTE: Not parsed by default, you must attach proper middleware See http://expressjs.com/4x/api.html#req.body

getBodyParam

getBodyParam :: forall e a. Decode a => String -> HandlerM (express :: EXPRESS | e) (Maybe a)

Get param from request's body. NOTE: Not parsed by default, you must attach proper middleware See http://expressjs.com/4x/api.html#req.body

getRoute

getRoute :: forall e. HandlerM (express :: EXPRESS | e) String

Return route that matched this request.

getCookie

getCookie :: forall e. String -> HandlerM (express :: EXPRESS | e) (Maybe String)

Get cookie param by its key.

getSignedCookie

getSignedCookie :: forall e. String -> HandlerM (express :: EXPRESS | e) (Maybe String)

Get signed cookie param by its key.

getRequestHeader

getRequestHeader :: forall e. String -> HandlerM (express :: EXPRESS | e) (Maybe String)

Get request header param.

accepts

accepts :: forall e. String -> HandlerM (express :: EXPRESS | e) (Maybe String)

Check if specified response type will be accepted by a client.

ifAccepts

ifAccepts :: forall e. String -> Handler e -> Handler e

Execute specified handler if client accepts specified response type.

acceptsCharset

acceptsCharset :: forall e. String -> HandlerM (express :: EXPRESS | e) (Maybe String)

Check if specified charset is accepted.

acceptsLanguage

acceptsLanguage :: forall e. String -> HandlerM (express :: EXPRESS | e) (Maybe String)

Check if specified language is accepted.

hasType

hasType :: forall e. String -> HandlerM (express :: EXPRESS | e) Boolean

Check if request's Content-Type field matches type. See http://expressjs.com/4x/api.html#req.is

getRemoteIp

getRemoteIp :: forall e. HandlerM (express :: EXPRESS | e) String

Return remote or upstream address.

getRemoteIps

getRemoteIps :: forall e. HandlerM (express :: EXPRESS | e) (Array String)

Return list of X-Forwarded-For proxies if any.

getPath

getPath :: forall e. HandlerM (express :: EXPRESS | e) String

Return request URL pathname.

getHostname

getHostname :: forall e. HandlerM (express :: EXPRESS | e) String

Return Host header field.

getSubdomains

getSubdomains :: forall e. HandlerM (express :: EXPRESS | e) (Array String)

Return array of subdomains.

isFresh

isFresh :: forall e. HandlerM (express :: EXPRESS | e) Boolean

Check that Last-Modified and/or ETag still matches.

isStale

isStale :: forall e. HandlerM (express :: EXPRESS | e) Boolean

Check that Last-Modified and/or ETag do not match.

isXhr

isXhr :: forall e. HandlerM (express :: EXPRESS | e) Boolean

Check if request was issued by XMLHttpRequest.

getProtocol

getProtocol :: forall e. HandlerM (express :: EXPRESS | e) (Maybe Protocol)

Return request protocol.

getMethod

getMethod :: forall e. HandlerM (express :: EXPRESS | e) (Maybe Method)

Return request HTTP method

getUrl

getUrl :: forall e. HandlerM (express :: EXPRESS | e) String

Return request URL (may be modified by other handlers/middleware).

getOriginalUrl

getOriginalUrl :: forall e. HandlerM (express :: EXPRESS | e) String

Return request original URL.

getUserData

getUserData :: forall e a. Decode a => String -> HandlerM (express :: EXPRESS | e) (Maybe a)

Retrieves the data from the request set with previous call to setUserData

setUserData

setUserData :: forall a e. String -> a -> Handler e

Sets the specified field of the userData object attached to the Request object to specified data