Response.md

July 11, 2018 ยท View on GitHub

Module Node.Express.Response

setStatus

setStatus :: Int -> Handler

Set status code.

getResponseHeader

getResponseHeader :: String -> HandlerM (Maybe String)

Return response header value.

setResponseHeader

setResponseHeader :: forall a. String -> a -> Handler

Set response header value.

headersSent

headersSent :: HandlerM Boolean

Check if headers have been sent already

setContentType

setContentType :: String -> Handler

Set Content-Type header.

setCookie

setCookie :: String -> String -> CookieOptions -> Handler

Set cookie by its name using specified options (maxAge, path, etc).

clearCookie

clearCookie :: String -> String -> Handler

Clear cookie.

send

send :: forall a. a -> Handler

Send a response. Could be object, string, buffer, etc.

sendJson

sendJson :: forall a. a -> Handler

Send a JSON response. Necessary headers are set automatically.

sendJsonp

sendJsonp :: forall a. a -> Handler

Send a JSON response with JSONP support.

redirect

redirect :: String -> Handler

Redirect to the given URL setting status to 302.

redirectWithStatus

redirectWithStatus :: Int -> String -> Handler

Redirect to the given URL using custom status.

setLocation

setLocation :: String -> Handler

Set Location header.

sendFile

sendFile :: String -> Handler

Send file by its path.

sendFileExt

sendFileExt :: forall o. String -> {  | o } -> (Error -> Effect Unit) -> Handler

Send file by its path using specified options and error handler. See http://expressjs.com/4x/api.html#res.sendfile

download

download :: String -> Handler

Transfer file as an attachment (will prompt user to download).

downloadExt

downloadExt :: String -> String -> (Error -> Effect Unit) -> Handler

Transfer file as an attachment using specified filename and error handler.

render

render :: forall a. String -> a -> Handler

Render a view with a view model object. Could be object, string, buffer, etc.

end

end :: Handler

Ends the response process.