-
Notifications
You must be signed in to change notification settings - Fork 333
Expand file tree
/
Copy pathRatpackApp.java
More file actions
41 lines (37 loc) · 1.63 KB
/
RatpackApp.java
File metadata and controls
41 lines (37 loc) · 1.63 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
package datadog.smoketest.ratpack;
import static ratpack.jackson.Jackson.json;
import com.fasterxml.jackson.databind.JsonNode;
import ratpack.server.RatpackServer;
public class RatpackApp {
public static void main(String[] args) throws Exception {
int port = Integer.parseInt(System.getProperty("ratpack.http.port", "8080"));
RatpackServer.start(
server ->
server
.serverConfig(config -> config.port(port))
.handlers(
chain ->
chain
.path(
"api_security/sampling/:status_code",
ctx -> {
ctx.getResponse()
.status(
Integer.parseInt(ctx.getPathTokens().get("status_code")))
.send("EXECUTED");
})
.path(
"api_security/response",
ctx ->
ctx.parse(JsonNode.class)
.then(
node -> {
ctx.getResponse().status(200);
ctx.render(json(node));
}))
.all(
ctx -> {
ctx.getResponse().status(404).send("Not Found");
})));
}
}