For example, I have a middleware app that reads the request, checks
the users cookies and sets up a session state from a 3rd party app.
However, since it runs on all requests, even requests for static pages
(images, html pages, css files, text files) still have this code
executing.
I would like to limit the middleware to a predefined set of routes, so
that the authentication is only run on routes that I am handling..
I *could* parse the requested URL in the middleware and determine if I
should run the code, but I was hoping there would be an easier way..
Thanks
Dav
--
Dav Glass
davg...@gmail.com
blog.davglass.com
+ Windows: n. - The most successful computer virus, ever. +
+ A computer without a Microsoft operating system is like a dog
without bricks tied to its head +
+ A Microsoft Certified Systems Engineer is to computing what a
McDonalds Certified Food Specialist is to fine cuisine +
--
You received this message because you are subscribed to the Google Groups "Express" group.
To post to this group, send email to expre...@googlegroups.com.
To unsubscribe from this group, send email to express-js+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/express-js?hl=en.
Thanks
--
Dav Glass
davg...@gmail.com
blog.davglass.com
+ Windows: n. - The most successful computer virus, ever. +
+ A computer without a Microsoft operating system is like a dog
without bricks tied to its head +
+ A Microsoft Certified Systems Engineer is to computing what a
McDonalds Certified Food Specialist is to fine cuisine +
Good to hear that it works for you. Although I believe that in
general you'll quickly hit a wall - for instance when you use routes
with params (my case, see example below *).
Also, as you suggested, in order not to have to make the route
filtering on the middleware itself, thus repeating yourself... Hence
my API proposal for per-route middleware of a few days ago.
TJ: is this anywhere in the near-term roadmap? I'd like to help. Start
perhaps by opening an issue on github or you keep track of these
features somewhere else?
Francisco
(*)
var app = express.createServer();
app.use('/test/:id', express.logger()) // never logs regardless of route
app.get('/', function(req, res){
res.send('Hello World');
});
app.get('/test/:id', function(req, res) {
res.send('Hello ' + req.params.id)
})
app.listen(3000);
2010/10/6 Dav Glass <davg...@gmail.com>:
Well yea... that looks great! Seriously, it promises a lot more
flexibility (without going the (fab) route - which is really cool but
is a whole other beast).
IMO this does not increase the learning curve because the basic API
remains the same. You can see this as a bonus, something you need not
to know upfront to get started.
On Thu, Oct 7, 2010 at 12:48 PM, vision media [ Tj Holowaychuk ]