Skip to content

Getting Started

Add the Luxis dependency to your pom.xml:

<dependency>
<groupId>io.kiw.luxis</groupId>
<artifactId>luxis</artifactId>
<version>0.1</version>
</dependency>

Create a handler by implementing JsonHandler:

public class HelloWorldHandler implements JsonHandler<HelloWorldRequest, HelloWorldResponse, AppState> {
@Override
public RequestPipeline<HelloWorldResponse> handle(HttpStream<HelloWorldRequest, AppState> e) {
return e.complete(ctx -> HttpResult.success(new HelloWorldResponse()));
}
}

Start the server and register your routes:

WebServer.start(routesRegister -> {
AppState appState = new AppState();
routesRegister.jsonRoute("/hello/world", Method.POST, appState.helloWorldState, HelloWorldRequest.class, new HelloWorldHandler());
return appState;
});

The jsonRoute method registers a typed JSON endpoint. It takes:

  • The path ("/hello/world")
  • The HTTP method (Method.POST)
  • The application state for this route
  • The request type class (used for JSON deserialization; pass Void.class for bodyless requests)
  • The handler instance

Learn how to build transformation pipelines in the Handler Pipeline guide.