Skip to content

matchedRoutes

reference
1 min readUpdated

Kind: Function

Source: src/helper/route/index.ts

Part of: Helper

Get matched routes in the handler

matchedRoutes gets the routes that match a handler. Use it when route-aware code needs to inspect the handler’s current route matches before performing follow-up work.

Signature

ts
function matchedRoutes(c: Context): RouterRoute[]

Parameters

NameType
cContext

Returns: RouterRoute[]

Diagram

mermaid
graph LR
  Handler[Handler] --> MatchedRoutes[matchedRoutes]
  MatchedRoutes --> Routes[Matched routes]
  Routes --> Consumer[Route-aware logic]

Usage

ts
import { matchedRoutes } from './helper/route'

const routes = matchedRoutes(handler)

for (const route of routes) {
  console.log(route)
}

AI Coding Instructions

  • Pass the handler instance associated with the current request or execution context.
  • Treat the returned routes as inspection data for route-aware behavior.
  • Keep route matching logic centralized through matchedRoutes rather than duplicating handler traversal.
  • Check the route shape before reading route-specific properties in downstream code.

Relationships

  • IMPORTS → GET_MATCH_RESULT
  • IMPORTS → getPattern
  • IMPORTS → splitRoutingPath

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)

  • handlersrc/middleware/method-not-allowed/index.ts:133

Was this page helpful?

Download as PDF
matchedRoutes — Hono (narrator proof)