mirror of
https://github.com/honojs/hono.git
synced 2024-12-01 10:51:01 +00:00
19 lines
410 B
TypeScript
19 lines
410 B
TypeScript
import type { Result, Router } from '../../router.ts'
|
|
import { Node } from './node.ts'
|
|
|
|
export class TrieRouter<T> implements Router<T> {
|
|
node: Node<T>
|
|
|
|
constructor() {
|
|
this.node = new Node()
|
|
}
|
|
|
|
add(method: string, path: string, handler: T) {
|
|
this.node.insert(method, path, handler)
|
|
}
|
|
|
|
match(method: string, path: string): Result<T> | null {
|
|
return this.node.search(method, path)
|
|
}
|
|
}
|