Skip to content

Response

$bolt.send(cContent)

Send text response (200 OK).

$bolt.send("Hello World")

$bolt.sendStatus(nStatus)

Send status code only.

$bolt.sendStatus(204)  # No Content

$bolt.sendWithStatus(nStatus, cContent)

Send text with custom status.

$bolt.sendWithStatus(201, "Created")

$bolt.json(aData)

Send JSON response.

$bolt.json([:name = "John", :age = 30])

$bolt.jsonWithStatus(nStatus, aData)

Send JSON with custom status.

$bolt.jsonWithStatus(201, [:id = 1, :created = true])

$bolt.sendFile(cFilePath)

Send file with auto-detected MIME type.

$bolt.sendFile("./files/report.pdf")

$bolt.sendFileAs(cFilePath, cContentType)

Send file with explicit MIME type.

$bolt.sendFileAs("./files/data.bin", "application/octet-stream")

$bolt.sendBinary(cBase64Data)

Send binary data as response.

$bolt.sendBinary(base64Data)

$bolt.sendBinaryAs(cBase64Data, cContentType)

Send binary data with a custom content type.

$bolt.sendBinaryAs(base64Data, "image/png")

$bolt.redirect(cUrl)

302 temporary redirect.

$bolt.redirect("/login")

$bolt.redirectPermanent(cUrl)

301 permanent redirect.

$bolt.redirectPermanent("/new-url")

$bolt.notFound()

Send 404 Not Found.

$bolt.notFound()

$bolt.badRequest(cMessage)

Send 400 Bad Request.

$bolt.badRequest("Invalid input")

$bolt.serverError(cMessage)

Send 500 Internal Server Error.

$bolt.serverError("Something went wrong")

$bolt.unauthorized()

Send 401 Unauthorized.

$bolt.unauthorized()

$bolt.forbidden()

Send 403 Forbidden.

$bolt.forbidden()