deno.land / x / hono@v4.2.5 / router.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
export const METHOD_NAME_ALL = 'ALL' as constexport const METHOD_NAME_ALL_LOWERCASE = 'all' as constexport const METHODS = ['get', 'post', 'put', 'delete', 'options', 'patch'] as constexport const MESSAGE_MATCHER_IS_ALREADY_BUILT = 'Can not add a route since the matcher is already built.'
export interface Router<T> { name: string add(method: string, path: string, handler: T): void match(method: string, path: string): Result<T>}
export type ParamIndexMap = Record<string, number>export type ParamStash = string[]export type Params = Record<string, string>export type Result<T> = [[T, ParamIndexMap][], ParamStash] | [[T, Params][]]/*The router returns the result of `match` in either format.
[[handler, paramIndexMap][], paramArray]e.g.[ [ [middlewareA, {}], // '*' [funcA, {'id': 0}], // '/user/:id/*' [funcB, {'id': 0, 'action': 1}], // '/user/:id/:action' ], ['123', 'abc']]
[[handler, params][]]e.g.[ [ [middlewareA, {}], // '*' [funcA, {'id': '123'}], // '/user/:id/*' [funcB, {'id': '123', 'action': 'abc'}], // '/user/:id/:action' ]]*/
export class UnsupportedPathError extends Error {}
hono

Version Info

Tagged at
a week ago