Skip to content

METHODS

reference
1 min readUpdated

Kind: Constant

Source: src/router.ts

Array of supported HTTP methods.

METHODS is an array of HTTP methods supported by the router. It acts as the method allowlist used when routing incoming requests and validating method-specific behavior.

Definition

ts
['get', 'post', 'put', 'delete', 'options', 'patch', 'query'] as const

Value

ts
['get', 'post', 'put', 'delete', 'options', 'patch', 'query'] as const

Diagram

mermaid
graph LR
  Request[Incoming request] --> Method[HTTP method]
  Method --> Methods[METHODS]
  Methods --> Router[Router handling]

Usage

ts
import { METHODS } from "./router";

function supportsMethod(method: string): boolean {
  return METHODS.includes(method);
}

if (supportsMethod(request.method)) {
  // Route the request
}

AI Coding Instructions

  • Keep METHODS aligned with the HTTP methods handled by the router.
  • Check request methods against METHODS before dispatching route handlers.
  • Update method-specific routing logic when adding or removing entries from METHODS.
  • Preserve the constant as the shared source of truth for supported methods.

Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

Imported by (1)

  • HonoOptionssrc/hono-base.ts:46

Was this page helpful?

Download as PDF
METHODS — Hono (narrator proof)