Getting Started
Installation
Section titled “Installation”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
Section titled “Create a Handler”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
Section titled “Start the Server”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.classfor bodyless requests) - The handler instance
Next Steps
Section titled “Next Steps”Learn how to build transformation pipelines in the Handler Pipeline guide.