Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/oak/router.ts>Router#allowedMethods

A middleware framework for handling HTTP with Deno, Node, Bun and Cloudflare Workers 🐿️ 🦕
Very Popular
Latest
method Router.prototype.allowedMethods
import { Router } from "https://deno.land/x/oak@v17.1.3/router.ts";

Middleware that handles requests for HTTP methods registered with the router. If none of the routes handle a method, then "not allowed" logic will be used. If a method is supported by some routes, but not the particular matched router, then "not implemented" will be returned.

The middleware will also automatically handle the OPTIONS method, responding with a 200 OK when the Allowed header sent to the allowed methods for a given route.

By default, a "not allowed" request will respond with a 405 Not Allowed and a "not implemented" will respond with a 501 Not Implemented. Setting the option .throw to true will cause the middleware to throw an HTTPError instead of setting the response status. The error can be overridden by providing a .notImplemented or .notAllowed method in the options, of which the value will be returned will be thrown instead of the HTTP error.

Parameters

optional
options: RouterAllowedMethodsOptions = [UNSUPPORTED]