dartist / express

A thin express-js inspired layer around Dart's primitive HttpServer APIs
Other
126 stars 11 forks source link

Added the possibility to add a chain of request handlers for a certain route #18

Closed SamVerschueren closed 10 years ago

SamVerschueren commented 10 years ago

As described in https://github.com/dartist/express/issues/16 I added the possibility to register a chain of request handlers. This allows the developer to use little pieces of middleware.

// Controllers
HomeController home = new HomeController();

// Middlewares
AuthMiddleware auth = new AuthMiddleware();

var app = new Express();
// The old way but still working with this update
app.get('/', home.index);

// The way it could be done with middleware
app.get('/users').then(auth.isSignedIn).then(home.users);

Because of the changes, it's not possible to chain them like this

var app = new Express();
app.get('/', home.index)
     ..get('/users', home.users);

If this pull request is accepted, I will update the README documentation.

mythz commented 10 years ago

Hi Sam,

You may have a dirty fork because GitHub wont allow automatically merging this pull-request. I suggest doing a clean pull before resubmitting the pull-request.

Change looks good tho! Allows better customization whilst Dart's cascade operator retains the ability to chain routes as before.

SamVerschueren commented 10 years ago

That's odd, thought I had the latest code. Will clean pull and add the changes again.

Will change the readme as well then with the latest updates.

SamVerschueren commented 10 years ago

This request can be denied and issue https://github.com/dartist/express/issues/16 can be closed.