Skip to content

Commit 1a8594b

Browse files
committed
support jex request scope
1 parent 0aba666 commit 1a8594b

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

http-generator-core/src/main/java/io/avaje/http/generator/core/RequestScopeTypes.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
package io.avaje.http.generator.core;
22

3-
import java.util.HashSet;
43
import java.util.Set;
54

65
class RequestScopeTypes {
76

87
private static final String JAVALIN_CONTEXT = "io.javalin.http.Context";
8+
private static final String JEX_CONTEXT = "io.avaje.jex.http.Context";
99
private static final String HELIDON_REQ = "io.helidon.webserver.ServerRequest";
1010
private static final String HELIDON_RES = "io.helidon.webserver.ServerResponse";
11-
private static final Set<String> TYPES = new HashSet<>();
1211

13-
static {
14-
TYPES.add(JAVALIN_CONTEXT);
15-
TYPES.add(HELIDON_REQ);
16-
TYPES.add(HELIDON_RES);
17-
}
12+
private static final Set<String> TYPES =
13+
Set.of(JAVALIN_CONTEXT, JEX_CONTEXT, HELIDON_REQ, HELIDON_RES);
1814

19-
/**
20-
* Return true if the type is a request scoped type.
21-
*/
15+
/** Return true if the type is a request scoped type. */
2216
static boolean isRequestType(String rawType) {
2317
return TYPES.contains(rawType);
2418
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.example.web.myapp;
2+
3+
import io.avaje.http.api.Controller;
4+
import io.avaje.http.api.Get;
5+
import io.avaje.http.api.Produces;
6+
import io.avaje.jex.http.Context;
7+
import jakarta.inject.Inject;
8+
9+
@Controller("/req-scoped")
10+
class ReqScopedController {
11+
12+
@Inject
13+
Context context;
14+
15+
@Produces("text/plain")
16+
@Get
17+
String getSimple() {
18+
return context.fullUrl();
19+
}
20+
}

0 commit comments

Comments
 (0)