A REST API framework for Flix with effect-oriented programming.
- Type-safe routing with path and query parameters
- JSON serialization/deserialization
- OpenAPI 3.0 specification generation
- Interactive API documentation with Scalar UI
- Effect-polymorphic handlers
def main(): Unit \ IO = {
let routes = List#{
Route.get("/hello", _ -> Response.ok("Hello, World!")),
Route.get("/hello/{name}", req -> {
let Request.Request(r) = req;
match Map.get("name", r#pathParams) {
case Some(name) => Response.ok("Hello, ${name}!")
case None => Response.badRequest("Missing name")
}
})
};
Server.serve(8080, routes)
}The framework provides:
- Route definition -
Route.get,Route.post,Route.put,Route.delete,Route.patch - Request handling - Access to path params, query params, and request body
- Response building -
Response.ok,Response.created,Response.notFound, etc. - JSON support -
Json.encodeandJson.decodewith type class instances - OpenAPI generation - Add metadata to routes for automatic API documentation
See examples/todo/ for a complete Todo API demonstrating:
- Custom effects with effect handlers
- CRUD operations
- OpenAPI documentation
- State management with regions
Run the example from the project root:
java -jar flix.jar run examples/todo/Main.flixServer starts at http://localhost:8080 with API docs at /api/docs.
See LICENSE.md