pre-major refactoring + ext api.

This commit is contained in:
Relism
2026-03-26 14:10:53 +01:00
parent f8c86e315f
commit 7b996b552b
57 changed files with 3823 additions and 117 deletions
@@ -37,31 +37,31 @@ class HttpServerTest {
server = new HttpServer(config);
// Setup some routes
server.get("/api/ping", (req, res) -> "pong");
server.get("/api/ping", (req, res) -> "pong").with();
server.post("/api/echo", (req, res) -> {
byte[] body = req.body().bytes();
return res.status(201).body(body); // echo body & change status
});
}).with();
server.get("/api/crash", (req, res) -> {
throw new RuntimeException("Simulated Crash");
});
}).with();
byte[] streamData = "streaming response body".getBytes(StandardCharsets.UTF_8);
server.get("/api/stream", (req, res) ->
res.stream(new ByteArrayInputStream(streamData), streamData.length));
res.stream(new ByteArrayInputStream(streamData), streamData.length)).with();
server.get("/api/chunked-out", (req, res) ->
res.chunked(new ByteArrayInputStream(streamData)));
res.chunked(new ByteArrayInputStream(streamData))).with();
server.get("/api/custom-header", (req, res) ->
res.body("ok").header("X-Flash", "works"));
res.body("ok").header("X-Flash", "works")).with();
server.post("/api/chunked-in", (req, res) -> {
byte[] body = req.body().bytes();
return res.body(body);
});
}).with();
server.start().get(5, TimeUnit.SECONDS);
}