Vulpix icon indicating copy to clipboard operation
Vulpix copied to clipboard

Middleware abstraction

Open Eastrall opened this issue 8 years ago • 3 comments

A good thing to do would be the Middleware abstraction to increase the modularity of Vulpix.

In the current case, we create the middlewares and call the exec method of the middleware. Example: app.Use(new BodyParser().Exec);

I guess what we could do is to create an interface, and all our middlewares would hinerit from this interface. So instead of giving the exec method, we'll give the concret middleware and work with the interface instead of the method.

Eastrall avatar Oct 27 '16 18:10 Eastrall

yes may be, why i choose to do that it's that way you can easily create a middleware with a lambda method, as express do, you know what i mean? May be a good solution will be to integrate both, middleware using interface or just a function and in back we create the middleware with this function

nicolasgere avatar Oct 27 '16 18:10 nicolasgere

Oh yes I see, you can create a middleware using lambda method:

app.Use(async (Req req, Res res) => {
    // TODO
});

Could be interesting indeed to integrate both options like you said 😉

Eastrall avatar Oct 27 '16 18:10 Eastrall

yes i think it will

nicolasgere avatar Oct 27 '16 18:10 nicolasgere