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
tsfunction routePath(c: Context, index: number): string
Parameters
| Name | Type |
|---|---|
c | Context |
index | number |
Returns: string
Diagram
mermaidgraph LR Handler[Registered handler] --> RoutePath[routePath] RoutePath --> Path[Registered route path]
Usage
tsimport { routePath } from './helper/route';
const registeredPath = routePath(userHandler);
console.log(`Handler is registered for: ${registeredPath}`);
AI Coding Instructions
- Call
routePathwith 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?