Skip to content

routePath

reference
1 min readUpdated

Kind: Function

Source: src/helper/route/index.ts

Part of: Helper

Get the route path registered within the handler

routePath reads the route path associated with a registered handler. Use it when middleware, diagnostics, or route-aware code needs the path stored on a handler instead of rebuilding it from request data.

Signature

ts
function routePath(c: Context, index: number): string

Parameters

NameType
cContext
indexnumber

Returns: string

Diagram

mermaid
graph LR
  Handler[Registered handler] --> RoutePath[routePath]
  RoutePath --> Path[Registered route path]

Usage

ts
import { routePath } from './helper/route';

const registeredPath = routePath(userHandler);

console.log(`Handler is registered for: ${registeredPath}`);

AI Coding Instructions

  • Call routePath with the handler that was registered with the router.
  • Keep route metadata attached to the handler when wrapping or composing handlers.
  • Do not derive the registered path from the incoming request when handler metadata is available.
  • Use the returned path for logging, diagnostics, or route-aware middleware behavior.

Was this page helpful?

Download as PDF
routePath — Hono (narrator proof)