avaje / avaje-http

Controller generation for Javalin, Helidon SE.
https://avaje.io/http/
Apache License 2.0
69 stars 13 forks source link

Ordering of filters and weight of http features #503

Open re-thc opened 1 week ago

re-thc commented 1 week ago

Hi, in using @filter is there a way to specify the order? The helidon docs says that they get applied based the order they're added to Helidon. Is that then based on how we add the beans / HttpFeature? There's no way at the moment to sort it in some specific order.

More generally speaking, filters and controllers create Http Features, which have weights that impact ordering. Is there any way to set this?

Also is each controller a HttpFeature? Can we group things?

Thanks!

SentryMan commented 1 week ago

Each controller is indeed a http feature, with each route within the controller registered in order of appearance. Filters are technically categorized as a route as well so you can group everything into a single controller.

SentryMan commented 1 week ago

Weight of regular controller routes rarely matter, as filters always go before routes even if registered after

rbygrave commented 2 days ago

Yes, we will need a way to order @Filters and that might be missing. For avaje-inject there is a @Priority and ability to get a list of components ordered by the priority value so that might be all that we are after at this stage.

For avaje-nima when adding HttpFeatures we'd change that from using beanScope.list(HttpFeature.class) to beanScope.listByPriority(HttpFeature.class).