class

Kemal::Exceptions::MethodNotAllowed

Inherits Exception < Reference < Object

Raised when the request path is routed for at least one other HTTP method.

RFC 9110 ยง15.5.6 separates this from a 404: the target resource exists, the method does not apply to it. allowed_methods lists the methods that do, and Kemal::ExceptionHandler renders it into the mandatory Allow response header.

Constructors

new(context : HTTP::Server::Context, allowed_methods : Array(String))

The message is the bare status reason because it doubles as the default response body, and reflecting the request back into it would put client-controlled text on the page. The request itself stays reachable through context.

Source

Instance methods

allowed_methods
Source
context
Source