diff --git a/http-generator-core/src/main/java/io/avaje/http/generator/core/RequestScopeTypes.java b/http-generator-core/src/main/java/io/avaje/http/generator/core/RequestScopeTypes.java index b9afd2c0..fdc862e9 100644 --- a/http-generator-core/src/main/java/io/avaje/http/generator/core/RequestScopeTypes.java +++ b/http-generator-core/src/main/java/io/avaje/http/generator/core/RequestScopeTypes.java @@ -1,24 +1,18 @@ package io.avaje.http.generator.core; -import java.util.HashSet; import java.util.Set; class RequestScopeTypes { private static final String JAVALIN_CONTEXT = "io.javalin.http.Context"; + private static final String JEX_CONTEXT = "io.avaje.jex.http.Context"; private static final String HELIDON_REQ = "io.helidon.webserver.ServerRequest"; private static final String HELIDON_RES = "io.helidon.webserver.ServerResponse"; - private static final Set TYPES = new HashSet<>(); - static { - TYPES.add(JAVALIN_CONTEXT); - TYPES.add(HELIDON_REQ); - TYPES.add(HELIDON_RES); - } + private static final Set TYPES = + Set.of(JAVALIN_CONTEXT, JEX_CONTEXT, HELIDON_REQ, HELIDON_RES); - /** - * Return true if the type is a request scoped type. - */ + /** Return true if the type is a request scoped type. */ static boolean isRequestType(String rawType) { return TYPES.contains(rawType); } diff --git a/tests/test-jex/src/main/java/org/example/web/myapp/ReqScopedController.java b/tests/test-jex/src/main/java/org/example/web/myapp/ReqScopedController.java new file mode 100644 index 00000000..5b634134 --- /dev/null +++ b/tests/test-jex/src/main/java/org/example/web/myapp/ReqScopedController.java @@ -0,0 +1,20 @@ +package org.example.web.myapp; + +import io.avaje.http.api.Controller; +import io.avaje.http.api.Get; +import io.avaje.http.api.Produces; +import io.avaje.jex.http.Context; +import jakarta.inject.Inject; + +@Controller("/req-scoped") +class ReqScopedController { + + @Inject + Context context; + + @Produces("text/plain") + @Get + String getSimple() { + return context.fullUrl(); + } +} \ No newline at end of file