You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -235,30 +238,15 @@ class Server extends Router {
235
238
*/
236
239
_create_route(record){
237
240
// Do not allow route creation once it is locked after a not found handler has been bound
238
-
if(this._routes_locked===true){
239
-
thrownewError(`Routes/Routers must not be created or used after the set_not_found_handler() has been set due to uWebsockets.js's internal router not allowing for this to occur. [${record.method.toUpperCase()}${record.pattern}]`)
241
+
if(this._routes_locked){
242
+
thrownewError(`Routes/Routers can not be created when server is started. [${record.method.toUpperCase()}${record.pattern}]`)
240
243
}
241
244
242
245
// Do not allow duplicate routes for performance/stability reasons
243
-
if(this._routes.get(record.method).get(record.pattern))thrownewError(`Failed to create route as duplicate routes are not allowed. Ensure that you do not have any routers or routes that try to handle requests at the same pattern. [${record.method.toUpperCase()}${record.pattern}]`)
244
-
245
-
// Process and combine middlewares for routes that support middlewares
246
-
// Initialize route-specific middlewares if they do not exist
if(this._routes.get(record.method).has(record.pattern))thrownewError(`Failed to create route as duplicate routes are not allowed. Ensure that you do not have any routers or routes that try to handle requests at the same pattern. [${record.method.toUpperCase()}${record.pattern}]`)
259
247
260
248
constroute=newRoute({
261
-
app: this,
249
+
appOptions: this._options,
262
250
method: record.method,
263
251
pattern: record.pattern,
264
252
options: record.options,
@@ -311,6 +299,10 @@ class Server extends Router {
311
299
* @param {Object} record
312
300
*/
313
301
_create_middleware(record){
302
+
// Do not allow middleware creation once routes is locked
303
+
if(this._routes_locked){
304
+
thrownewError(`Middlewares can not be created when server is started. [${record.pattern}]`)
305
+
}
314
306
// Initialize middlewares array for specified pattern
0 commit comments