Skip to content
Advertisement

How to programmatically declare a route in Quarkus?

As seen in the documentation, the standard way of declaring a route in Quarkus is with the @Path() annotation, like so :

JavaScript

This will create the route GET /MyPath. However, @Path being an annotation, I have to give it constant expression.

I would like to be able to declare a route with a non constant expression, something like @Path(MyClass.class.getSimpleName())

I tried to implement something like this:

JavaScript

This would create the route GET /MyClass But I have no idea how to implement declareRoute(). I tried to inject the Vertx Router since Quarkus seems to use it, but I did not find a way to add a route. Is this doable, and if so, how ?

Advertisement

Answer

You essentially need to do something like:

JavaScript

See this for more information

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement