forked from jooby-project/jooby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstanceRouter.java
More file actions
44 lines (36 loc) · 847 Bytes
/
Copy pathInstanceRouter.java
File metadata and controls
44 lines (36 loc) · 847 Bytes
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
package examples;
import io.jooby.Context;
import io.jooby.Route;
import io.jooby.annotations.DELETE;
import io.jooby.annotations.GET;
import io.jooby.annotations.POST;
import io.jooby.annotations.Path;
import org.slf4j.LoggerFactory;
import static org.junit.jupiter.api.Assertions.assertEquals;
@Path("/")
public class InstanceRouter {
@GET
@POST
@Role("some")
public String getIt(Route route) {
assertEquals("some", route.attribute("role"));
return "Got it!";
}
@GET
@Path("/subpath")
public String subpath() {
return "OK";
}
@DELETE
@Path("/void")
public void noContent() {
}
@GET
@Path("/voidwriter")
public void writer(Context ctx) throws Exception {
LoggerFactory.getLogger(getClass()).info("blocking");
ctx.responseWriter(writer -> {
writer.println("writer");
});
}
}