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

x/superdeno/test/deps.ts>Oak.Router#allowedMethods

Super-agent driven library for testing Deno HTTP servers.
Go to Latest
method Oak.Router.prototype.allowedMethods
import { Oak } from "https://deno.land/x/superdeno@4.8.0/test/deps.ts";
const { Router } = Oak;

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]