mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-03-14 08:48:13 -04:00
21 lines
418 B
TypeScript
21 lines
418 B
TypeScript
![]() |
class Router {
|
||
|
private router = new Map<string, routeHandler>()
|
||
|
|
||
|
get (url: string, callback: routeHandler): void {
|
||
|
this.router.set(url, callback)
|
||
|
}
|
||
|
post (url: string, callback: routeHandler): void {
|
||
|
this.router.set(url, callback)
|
||
|
}
|
||
|
|
||
|
getHandler (url: string) {
|
||
|
if (this.router.has(url)) {
|
||
|
return this.router.get(url)
|
||
|
} else {
|
||
|
return null
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default new Router()
|