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
Code similar to #197 but entirely different issue:
importexpressfrom'express';importHyperExpressfrom'hyper-express';constUSE_HYPER_EXPRESS=true;constapp=USE_HYPER_EXPRESS ? newHyperExpress.Server() : express();app.get('/',(req,res)=>{res.send('Hello World!');});app.get('/:name',(req,res,next)=>{if(req.params.name==='tester'){returnnext();}res.send(`Hello ${req.params.name}!`);});app.get('/:name2',(req,res)=>{res.send(`Greetings, ${req.params.name2}.`);});if(USE_HYPER_EXPRESS){app.listen(3001).then(()=>{console.log('Listening on port 3001');}).catch((err)=>{console.error(err);});}else{app.listen(3001,()=>{console.log('Listening on port 3001');});}
If you use express:
Going to localhost:3001/test will return Hello test!
Going to localhost:3001/tester will return Greetings, tester.
If you use hyper-express:
Going to localhost:3001/test will return Hello test!
Going to localhost:3001/tester will return HyperExpress: Uncaught Exception Occured (TypeError: next is not a function)
The text was updated successfully, but these errors were encountered:
I see, so this behavior seems to occur because Express allows usage of overlapping routes while uWebsockets.js the underlying performant webserver that powers hyper-express will serve the first route it matches natively.
With that said, adding support for this should not be too difficult given hyper-express can simply match overlapping routes, then execute the first one and provide a next() iterator which lets you chain multiple routes similar to middlewares throughout the request lifecycle.
I will begin exploring an implementation for this feature and potentially have it rolled out soon.
Hi, are you still working on this? I don't believe this and #197 should have been closed since they're ongoing issues. These issues are one of the biggest roadblocks in using this library, would be really nice to see these reopened and fixed.
Code similar to #197 but entirely different issue:
If you use
express
:localhost:3001/test
will returnHello test!
localhost:3001/tester
will returnGreetings, tester.
If you use
hyper-express
:localhost:3001/test
will returnHello test!
localhost:3001/tester
will returnHyperExpress: Uncaught Exception Occured
(TypeError: next is not a function
)The text was updated successfully, but these errors were encountered: