package org.example;
import io.avaje.jex.Jex;
import io.avaje.jsonb.Json;
public class Main {
@Json
record Something(String name, int value) {
}
static void main() {
Jex.create()
.get("/", ctx -> ctx.json(new Something("John", 123)))
.error(
IllegalStateException.class,
(ctx, exception) -> ctx.status(500).text(exception.getMessage()))
.port(8080)
.start();
}
}
plugins {
id("java")
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
implementation("io.avaje:avaje-jex:3.3")
implementation("io.avaje:avaje-jsonb:3.8")
annotationProcessor("io.avaje:avaje-jsonb-generator:3.8")
testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
tasks.test {
useJUnitPlatform()
}