RouteResponse

RouteResponse

A response object represents the response to a request. It contains the status code, the body of the response, and the headers.

Properties

NameTypeDescription
setStatus(number) -> nilSets the status code of the response.
setHeader(string, string) -> nilSets a header in the response.
send(string, string?) -> nilSends a response to the client.
json(any) -> nilSends a JSON response to the client.
redirect(string) -> nilRedirects the client to a different URL.
html(string, { [string]: any }?) -> nilSends an HTML response to the client.

Example

local aurora = require("aurora")

aurora.get("/hello", function(req, res)
    res.send("Hello, world!")
end)

aurora.serve()
type RouteResponse = {
    setStatus: (number) -> nil,
    setHeader: (string, string) -> nil,
    send: (string, string?) -> nil,
    json: (any) -> nil,
    redirect: (string) -> nil,
    html: (string, { [string]: any }?) -> nil,
}