Module

Erl.Cowboy.Req

Bindings for cowboy_req

The Req type (corresponding to req()) is core to the use of cowboy, containing information about request and response. Many functions operating on Req are pure, producing an updated Req if required to update some fields, e.g. when setting a header, but others produce a result in Effect as even though they may update the Req, they also cause side-effects such as sending traffic on the network (eg reply).

#StatusCode

newtype StatusCode

Constructors

#Headers

#Req

data Req

#reply

reply :: StatusCode -> Headers -> IOData -> Req -> Effect Req

Send the reply including the given body content (cowboy_req:reply/4)

#replyWithoutBody

replyWithoutBody :: StatusCode -> Headers -> Req -> Effect Req

Send the reply without setting the body (cowboy_req:reply/3)

#replyWithFile

replyWithFile :: StatusCode -> Headers -> String -> Req -> Effect Req

Send the reply including a file as the body

#replyStatus

replyStatus :: StatusCode -> Req -> Effect Req

Send the reply with already set headers and body (cowboy_req:reply/2)

#method

#Version

#version

#scheme

#binding

binding :: forall a. Atom -> Req -> Maybe a

#bindingWithDefault

bindingWithDefault :: forall a. Atom -> Req -> a -> a

#pathInfo

#host

#port

port :: Req -> Int

#path

#qs

qs :: Req -> String

#header

#headers

#ReadBodyResult

#ReadUrlEncodedBodyResult

#setCookie

#setCookieWithOpts

#CookieOpts

type CookieOpts = { domain :: String, http_only :: Boolean, max_age :: Int, path :: String, same_site :: Atom, secure :: Boolean }

#setHeader

#setBody

setBody :: String -> Req -> Req

Set response body. As should be apparent from the type, this does not actually send the body but merely sets it in the Req, the body is sent once reply is called.

#IpAddress

#parseCookies

#streamReply

#streamBody

#streamBodyFinal

#setIdleTimeout

Modules