pmlopes / yoke

Yoke is a middleware framework for Vert.x
http://pmlopes.github.io/yoke/
Apache License 2.0
157 stars 44 forks source link

Add filter-base middleware selection #132

Closed ddossot closed 10 years ago

ddossot commented 10 years ago

It's currently possible to filter middlewares based on routes: use(route, middleware)

It would be super powerful to be able to do the same with a more generic YokeRequestFilter (with accept(request) -> boolean) like this: use(filter, middleware).

Rationale: being able to use other request properties than path for filtering, like for example the value of the Accept header.

pmlopes commented 10 years ago

not totally sure about return boolean since if you want to filter you might also want to filter say based on some backend database value (say oauth tokens) then you need to be asynchronous...

On the other end can we just make a middleware a la Router that is instantiated with a filter interface and the just has a method use(Middleware... middlewares) ?

ddossot commented 10 years ago

Indeed, creating a middleware that conditionally delegates to another middleware, or list of middlewares, would work too. Thanks for your feedback.