tsframework / ts-framework

A Web Framework for Nodejs
http://tsframework.github.io
MIT License
43 stars 6 forks source link

Proposal: Implement middleware #33

Closed atrakeur closed 8 years ago

atrakeur commented 8 years ago

For now, router only dispatch a given request to a given route.

Maybe we should implement a middleware system (or filter system).

Basicaly it's a piece of code that executes before the controller code and can handle things like authentification and XCSRF protection.

Also I'm not sure how we can make a fluent syntax with the decorator. Something like @Middleware is possible but can become tedious and clutered very fast.

Basicaly the goal is to replace parts of the actual Router.dispatch() method with middlewares. It's also important because express provide this functionnality out of the box (also Laravel and Zend does too)