Skip to content

Commit 52de85f

Browse files
committed
fix role short names
1 parent a324af1 commit 52de85f

File tree

2 files changed

+11
-4
lines changed
  • http-generator-core/src/main/java/io/avaje/http/generator/core
  • tests/test-javalin-jsonb/src/main/java/org/example/myapp/web/test

2 files changed

+11
-4
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ public static String shortName(String fullType) {
7575
int p = fullType.lastIndexOf('.');
7676
if (p == -1) {
7777
return fullType;
78-
} else if (fullType.startsWith("java")) {
78+
} else if (fullType.startsWith("java")
79+
|| fullType.contains("io.javalin.security.RouteRole")
80+
|| fullType.contains("io.avaje.jex.Role")) {
7981
return fullType.substring(p + 1);
8082
} else {
8183
var result = "";

tests/test-javalin-jsonb/src/main/java/org/example/myapp/web/test/TestController.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,24 @@
44
import java.util.Map;
55
import java.util.Set;
66

7+
import org.example.myapp.web.AppRoles;
8+
import org.example.myapp.web.Roles;
9+
710
import io.avaje.http.api.Controller;
811
import io.avaje.http.api.Form;
912
import io.avaje.http.api.Get;
1013
import io.avaje.http.api.Header;
14+
import io.avaje.http.api.MatrixParam;
1115
import io.avaje.http.api.MediaType;
1216
import io.avaje.http.api.Path;
1317
import io.avaje.http.api.Post;
1418
import io.avaje.http.api.Produces;
1519
import io.avaje.http.api.Put;
16-
import io.avaje.http.api.MatrixParam;
1720
import io.javalin.http.Context;
1821

1922
@Path("test/")
2023
@Controller
24+
@Roles(AppRoles.ANYONE)
2125
public class TestController {
2226

2327
@Get
@@ -107,7 +111,8 @@ String testForm(String name, String email, String url) {
107111
String testFormBean(MyForm form) {
108112
return form.name + "|" + form.email + "|" + form.url;
109113
}
110-
114+
115+
@Roles(AppRoles.ADMIN)
111116
@Get("/withMatrixParam/{type-1;category;vendor-34}/{range;style}")
112117
void neo(
113118
@MatrixParam("type-1") String type,
@@ -116,6 +121,6 @@ void neo(
116121
String range,
117122
String style) {
118123

119-
System.out.println("Ever have that feeling where you're not sure if you're awake or dreaming?");
124+
System.out.println("Ever have that feeling where you're not sure if you're awake or dreaming?");
120125
}
121126
}

0 commit comments

Comments
 (0)