Skip to main content

Configuration

LigeroConfig is an immutable record; values resolve with precedence builder > environment variables > classpath ligero.properties > defaults.

Ligero app = Ligero.create(LigeroConfig.builder()
.host("0.0.0.0")
.port(8080) // 0 = ephemeral (tests)
.contextPath("/api")
.maxBodyBytes(5 * 1024 * 1024) // -> 413 beyond this
.virtualThreads(true)
.gzip(true)
.gzipMinBytes(1024)
.shutdownGrace(Duration.ofSeconds(30))
.build());
BuilderEnv varPropertyDefault
hostLIGERO_HOSTligero.host0.0.0.0
portLIGERO_PORTligero.port8080
contextPathLIGERO_CONTEXT_PATHligero.contextPath/
maxBodyBytesLIGERO_MAX_BODY_BYTESligero.maxBodyBytes10 MiB
virtualThreadsLIGERO_VIRTUAL_THREADSligero.virtualThreadstrue
gzipLIGERO_GZIPligero.gzipfalse
gzipMinBytesLIGERO_GZIP_MIN_BYTESligero.gzipMinBytes1024
shutdownGraceLIGERO_SHUTDOWN_GRACE_SECONDSligero.shutdownGraceSeconds10 s

Ligero.create() (no arguments) loads defaults + properties + env, so a container deployment configures itself entirely through LIGERO_* variables.

Graceful shutdown

app.stop() drains in-flight requests within shutdownGrace. Typical wiring:

app.start();
Runtime.getRuntime().addShutdownHook(new Thread(app::stop));