quarkus with a vertx session handler #29980
Answered
by
tomschulze
tomschulze
asked this question in
Q&A
-
I am trying to migrate a Vert.x application to Quarkus. I need to add middleware handlers to my router. In the case below I want to add a session handler. I don't understand why it does not work. When I access the route "/", Quarkus throws a package me.tom.testapp;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
import io.quarkus.vertx.web.Route;
import io.vertx.core.Vertx;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.handler.SessionHandler;
import io.vertx.ext.web.sstore.LocalSessionStore;
@ApplicationScoped
public class Routes {
public void init(@Observes Router router, Vertx vertx) {
router
.route()
.handler(SessionHandler.create(LocalSessionStore.create(vertx)));
}
@Route(path = "/")
public void helloWorld(RoutingContext rc) {
rc.session().put("test", "test");
rc.response().end("hello");
}
@Route(path = "/test")
public void yoyo(RoutingContext rc) {
String test = rc.session().get("test");
rc.response().end(test);
}
} That is the route
|
Beta Was this translation helpful? Give feedback.
Answered by
tomschulze
Dec 20, 2022
Replies: 1 comment
-
The culprit is the route order. Changing the code to router
.route()
.order(0)
.handler(SessionHandler.create(LocalSessionStore.create(vertx))); works. Prior to the change |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mkouba
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The culprit is the route order. Changing the code to
works. Prior to the change
helloWorld()
was executed first.