class

Kemal::Controller::Halt

Inherits Exception < Reference < Object

Raised by halt to abort the current request.

The generated route handler rescues it, applies status_code to the response and returns response as the body. WebSocket routes close the socket with HTTP::WebSocket::CloseCode::PolicyViolation instead, using response as the reason.

Raise it directly when halt isn't in scope, e.g. from a helper defined in an included module rather than in the controller itself:

raise Kemal::Controller::Halt.new(403, "Forbidden")

Constructors

new(status : HTTP::Status | Int32 = 200, response : String = "")
Source

Instance methods

response

The response body, or the WebSocket close reason.

Source
status_code

The HTTP status code to respond with.

Source