commit | 2b7c37cb7a0b3350b1a57b42d99124801f9b59b7 | [log] [tgz] |
---|---|---|
author | dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> | Mon Jul 24 02:39:16 2023 +0000 |
committer | GitHub <noreply@github.com> | Mon Jul 24 02:39:16 2023 +0000 |
tree | 35b44cc8cc690ac6a15889da5f489f07dfa8db1d | |
parent | 379a822f91c769a19abe69381434a27613ba7ff9 [diff] |
Bump junit:junit from 4.13 to 4.13.1 Bumps [junit:junit](https://github.com/junit-team/junit4) from 4.13 to 4.13.1. - [Release notes](https://github.com/junit-team/junit4/releases) - [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.13.1.md) - [Commits](https://github.com/junit-team/junit4/compare/r4.13...r4.13.1) --- updated-dependencies: - dependency-name: junit:junit dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com>
This repository is one of the results of a GSOC 2020 (Google Summer of Code) project for OpenWebBeans at ASF. Its intention is to provide a very small and lightweight HTTP server with CDI functionalities at its core, that should hopefully become natively runnable soon, as a GraalVM native-image. For the server components, Netty is used. This repository contains the API, implementation and a showcase in the respective sub-modules.
Here's an example for how to configure and build this server:
public HttpServer init() { return new HttpServer.Builder() .port(0) //applies a random valid port .ssl(false) .host("localhost") .build(); }
And here's how you can use the API with the HttpHandler
annotation:
@Inject private HttpServer httpServer; @HttpHandler(method = {HttpMethod.GET}, url = "/hello/*", matching = Matching.WILDCARD) public CompletionStage<Response> helloWorld(Request request) { String responseContent = "Hello World from " + httpServer.getHost() + ":" + httpServer.getPort() + " !"; ByteArrayInputStream output = new ByteArrayInputStream(responseContent.getBytes(StandardCharsets.UTF_8)); return CompletableFuture.supplyAsync(() -> { Response response = new Response(); response.addHeader("statusCode", "200"); response.addHeader("content-type", "text/html"); response.setOutput(output); return response; }); }
This is a reactive example with CompletionStage; you can also straight up use Response as the method return type. The formal requirements of a valid handler method and annotation are:
CompletionStage<Response>
or Response
Request
Matching.WILDCARD
needs a star at the end of the given urlFor more examples please refer to the respective showcase. The implementation is found here.
PeecoExtension.java
collects all methods that are annotated with our @HttpHandler
and starts up the Netty Server. The flow of the request/response handling is then happening in PeecoChannelHandler.java
.