forked from jooby-project/jooby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoutes.java
More file actions
60 lines (48 loc) · 1.42 KB
/
Routes.java
File metadata and controls
60 lines (48 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package source;
import io.jooby.Context;
import io.jooby.Reified;
import io.jooby.annotations.GET;
import io.jooby.annotations.POST;
import io.jooby.annotations.Path;
import java.util.Arrays;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
@Path("/path")
public class Routes {
@GET
public String doIt(Context ctx) {
assertEquals(String.class, ctx.getRoute().getReturnType());
return ctx.getRequestPath();
}
@GET("/subpath")
public List<String> subpath(Context ctx) {
assertEquals(Reified.list(String.class).getType(), ctx.getRoute().getReturnType());
return Arrays.asList(ctx.getRequestPath());
}
@GET("/object")
public Object object(Context ctx) {
assertEquals(Object.class, ctx.getRoute().getReturnType());
return ctx;
}
@POST("/post")
public JavaBeanParam post(Context ctx) {
assertEquals(JavaBeanParam.class, ctx.getRoute().getReturnType());
return new JavaBeanParam();
}
@GET(path = "/pathAttributeWork")
public String pathAttributeWork(Context ctx) {
return ctx.getRequestPath();
}
@GET(path = "/path", value = "/value")
public String pathvalue(Context ctx) {
return ctx.getRequestPath();
}
@GET(value = {"/path1", "/path2"})
public String pathvalueArray(Context ctx) {
return ctx.getRequestPath();
}
@POST(path = {"/path1", "/path2"})
public String pathArray(Context ctx) {
return ctx.getRequestPath();
}
}