add duplicated routes check
This commit is contained in:
parent
be5c65e759
commit
4ed1c7c812
|
@ -130,6 +130,10 @@ export class HTTPServer {
|
|||
|
||||
add(method: HTTPMethod, path: string, handler: RouteHandler) {
|
||||
const route = new Route(path, method, handler);
|
||||
if (this.routes.has(route.routeName)) {
|
||||
console.log(`${route.routeName} already registered!`);
|
||||
return;
|
||||
}
|
||||
this.routes.set(route.routeName, route);
|
||||
console.log(`${route.routeName} added`);
|
||||
}
|
||||
|
|
Reference in New Issue
Block a user