Skip to content

Latest commit

 

History

History
156 lines (97 loc) · 2.64 KB

Response.md

File metadata and controls

156 lines (97 loc) · 2.64 KB

Module Node.Express.Response

setStatus

setStatus :: forall e. Int -> Handler e

Set status code.

getResponseHeader

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

Return response header value.

setResponseHeader

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

Set response header value.

headersSent

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

Check if headers have been sent already

setCookie

setCookie :: forall e. String -> String -> CookieOptions -> Handler e

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

clearCookie

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

Clear cookie.

end

end :: forall e. Handler e

Ends the response process.

send

send :: forall e a. a -> Handler e

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

sendJson

sendJson :: forall e a. a -> Handler e

Send a JSON response. Necessary headers are set automatically.

sendJsonp

sendJsonp :: forall e a. a -> Handler e

Send a JSON response with JSONP support.

redirect

redirect :: forall e. String -> Handler e

Redirect to the given URL setting status to 302.

redirectWithStatus

redirectWithStatus :: forall e. Int -> String -> Handler e

Redirect to the given URL using custom status.

setLocation

setLocation :: forall e. String -> Handler e

Set Location header.

setContentType

setContentType :: forall e. String -> Handler e

Set Content-Type header.

sendFile

sendFile :: forall e. String -> Handler e

Send file by its path.

sendFileExt

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

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

download

download :: forall e. String -> Handler e

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

downloadExt

downloadExt :: forall e. String -> String -> (Error -> ExpressM e Unit) -> Handler e

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

render

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

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