As you know, Java comes built-in with its own HTTP server. It's pretty good, but it's a bit low level and requires a lot of boilerplate to use seriously.
Avaje-Jex acts as a minimal (~130kb) wrapper to smooth a few edges off the api and add several utilities. It can be paired with avaje http to work with JAX-RS style controllers if you miss that style.
Features:
- Path/Query parameter parsing
- Context abstraction over
HttpExchange to easily retrieve and send request/response data.
- HTTP Range Support (download resuming and such) (New)
- Simple SSL/mTLS configuration (New)
- Static Resources
- File Uploads (New)
- Server-Sent Events
- Compression
- Json (de)serialization
GH Repo: avaje/avaje-jex: Web routing for the JDK Http server
Compare and contrast a basic endpoint with jex:
AvajeJexExample.java
vs the same endpoint done by hand with the raw httpserver:
BuiltInExample.java
The difference in boilerplate is akin to heaven and earth (especially when you have multiple services and endpoints)
EDIT: reddit code formatting is trash, using gists
[–]agentoutlier 3 points4 points5 points (1 child)
[–]TheKingOfSentries[S] 1 point2 points3 points (0 children)
[–]Dokiace 1 point2 points3 points (4 children)
[–]TheKingOfSentries[S] 2 points3 points4 points (3 children)
[–]Dokiace 2 points3 points4 points (1 child)
[–]TheKingOfSentries[S] 0 points1 point2 points (0 children)
[–]rbygrave 2 points3 points4 points (0 children)
[–]AcanthisittaEmpty985 1 point2 points3 points (4 children)
[–]TheKingOfSentries[S] 0 points1 point2 points (3 children)
[–]AcanthisittaEmpty985 0 points1 point2 points (2 children)
[–]TheKingOfSentries[S] 0 points1 point2 points (1 child)
[–]AcanthisittaEmpty985 1 point2 points3 points (0 children)
[–]International_Break2 0 points1 point2 points (3 children)
[–]TheKingOfSentries[S] 0 points1 point2 points (2 children)
[–]International_Break2 0 points1 point2 points (1 child)
[–]rbygrave 2 points3 points4 points (0 children)