regex - Ignoring words in an express route -
i have following routes:
app.get('/blah/query.json', dosomething); app.get('/blah/:id.:format', dosomethingelse);
currently both routes continue on route 1 (query.json) called , route 2 called (:id.:format). how can exclude call route 2 if route 1 called. tried this:
app.get('/blah^\/(?!query)(:id.:format)$', dosomethingelse);
but this, , several variations of this, didn't seem work. found post references express code here. looking @ code , trying different things still having trouble getting "if not query" expression work.
any thoughts?
what if set semaphore following?:
var sempahore_execute_second = true; app.get('/blah/query.json', function(req,res,next){ sempahore_execute_second = false; }); app.get('/blah/:id.:format', function(req,res,next){ if (sempahore_execute_second) { // execute code here. }; })); // or better: app.get('/blah/:id.:format', function(req,res,next){ if (sempahore_execute_second) return next(); // execute code here. }));
i know bit messy , should forward solution, maybe can @ moment.
Comments
Post a Comment