mirror of
https://github.com/honojs/hono.git
synced 2024-12-01 10:51:01 +00:00
a149dddfdc
* refactor(router): Export supported HTTP methods. * refactor(router): Introduce UnsupportedPathError. * feat(static-router): Introduce StaticRouter. * feat(reg-exp-router): Add "allowAmbiguous" option to RegExpRouter. * feat(smart-router): Introduce SmartRouter. * feat(hono): Make SmartRouter the default router. * chore: denoify * refactor(smart-router): routers is never undefined. * chore: denoify * refactor: Fix test for SmartRouter.
16 lines
470 B
TypeScript
16 lines
470 B
TypeScript
export const METHOD_NAME_ALL = 'ALL' as const
|
|
export const METHOD_NAME_ALL_LOWERCASE = 'all' as const
|
|
export const METHODS = ['get', 'post', 'put', 'delete', 'head', 'options', 'patch'] as const
|
|
|
|
export interface Router<T> {
|
|
add(method: string, path: string, handler: T): void
|
|
match(method: string, path: string): Result<T> | null
|
|
}
|
|
|
|
export interface Result<T> {
|
|
handlers: T[]
|
|
params: Record<string, string>
|
|
}
|
|
|
|
export class UnsupportedPathError extends Error {}
|