Skip to content

Commit

Permalink
Allow injection of RoutingContext in RESTEasy Reactive
Browse files Browse the repository at this point in the history
This is done in order to stay in line with what Quarkus allows
when using RESTEasy Classic

Fixes: #16934
  • Loading branch information
geoand committed May 2, 2021
1 parent a70fba6 commit 46a41de
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
package io.quarkus.resteasy.reactive.server.test.simple;

import java.util.Objects;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;

import io.vertx.ext.web.RoutingContext;

@RequestScoped
public class HelloService {

@Inject
RoutingContext context;

public String sayHello() {
Objects.requireNonNull(context);
return "Hello";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.jboss.resteasy.reactive.server.core.ResteasyReactiveRequestContext;

import io.quarkus.vertx.http.runtime.CurrentVertxRequest;
import io.vertx.ext.web.RoutingContext;

public class QuarkusCurrentRequest implements CurrentRequest {

Expand All @@ -20,6 +21,12 @@ public ResteasyReactiveRequestContext get() {

@Override
public void set(ResteasyReactiveRequestContext set) {
currentVertxRequest.setOtherHttpContextObject(set);
if (set == null) {
currentVertxRequest.setOtherHttpContextObject(null);
currentVertxRequest.setCurrent(null);
} else {
currentVertxRequest.setOtherHttpContextObject(set);
currentVertxRequest.setCurrent(set.unwrap(RoutingContext.class));
}
}
}

0 comments on commit 46a41de

Please sign in to comment.