Skip to content

Commit

Permalink
Merge pull request #16936 from geoand/#16934
Browse files Browse the repository at this point in the history
Allow injection of RoutingContext in RESTEasy Reactive
  • Loading branch information
geoand authored May 3, 2021
2 parents efb3f2d + 46a41de commit 5a7a74d
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 5a7a74d

Please sign in to comment.