7c1edffd6e95fe07d2d3b36fadae10c0c3dcef40
- Add Middleware.java: @FunctionalInterface with Middleware.of() chain composition and andThen() helper; zero allocations on hot-path - Remove flash/Main.java from versioning (scratch/test entrypoint) - Update .gitignore: exclude flash-bench/, nuxt-shadcn-dashboard/, /dev/, /docs/, Main.java, *.text — all root-level local artifacts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Flash
A high-performance HTTP/1.1 server library for Java 21+, built for low-latency workloads.
Features
- Virtual threads — one virtual thread per connection via
Executors.newVirtualThreadPerTaskExecutor() - Zero-allocation hot path — header buffer reused across keep-alive requests;
ByteViewslices avoid copies - Fast routing —
fpr-corecompiles routes into a byte-level finite automaton at first request; path params viaPathParams - Two-tier router — mounted sub-routers matched by longest prefix, then
FastPathRouterImplfallback - Middleware chain — composable
Middlewarelambdas fused at registration time (no per-request allocation) - Chunked transfer —
ChunkedInputStreamde-chunks on the fly, keeps socket positioned for pipelining - Request body —
bytes()for full materialization orstream()for zero-copy streaming
Requirements
- Java 21+
- Maven 3.8+
Build
mvn clean package -DskipTests
Quick start
HttpServer server = new HttpServer(
HttpServerConfiguration.builder().port(8080).build()
);
server.get("/hello", (req, res) -> "Hello, world!");
server.register(new MyHandler()); // @Route(path="/...", method=GET)
server.start().thenRun(() -> System.out.println("Listening on :8080"));
Handler styles
Lambda:
server.get("/ping", (req, res) -> "pong");
Class-based (@Route):
@Route(path = "/users/{id}", method = HttpMethod.GET)
public class GetUser extends RequestHandler {
@Override
public Object handle(Request req, Response res) {
String id = req.pathParam("id");
return "{\"id\":\"" + id + "\"}";
}
}
Middleware:
Middleware cors = next -> (req, res) -> {
res.header("Access-Control-Allow-Origin", "*");
return next.handle(req, res);
};
server.register(new GetUser(), cors);
Maven dependency
<repositories>
<repository>
<id>relism-releases</id>
<url>https://maven.relism.dev/releases</url>
</repository>
</repositories>
<dependency>
<groupId>dev.relism</groupId>
<artifactId>flash</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
Languages
Java
97.3%
JavaScript
2.2%
HTML
0.4%