The Web Framework combines multiple JavaWebStack libraries with glue code and helpers to allow fast web development
classMyWebAppextendsWebApplication {
protectedvoidsetupConfig(Configconfig) {
config.addEnvFile(".env");
}
protectedvoidsetupModels(SQLsql) throwsORMConfigurationException {
}
protectedvoidsetupServer(HTTPServerserver) {
server.get("/", exchange -> {
return"Hello World";
});
server.controller(newExampleController());
}
}
// Example Controller@PathPrefix("/api/v1")
publicclassExampleControllerextendsHttpController {
@Get("/{name}")
publicGetSomethingResponsegetSomething(@Path("name") Stringname) {
GetSomethingResponseresponse = newGetSomethingResponse();
response.name = name;
// Automatically Serializes it to JSON if Accept header is not set.returnresponse;
}
@Post// If empty it uses the /api/v1 routepublicbooleancreateSomething(@BodyCreateSomethingRequestrequest) {
// @Body uses JSON for default to unserialize it into an object of the given type, but if the Accept header is set, you can use yaml or form System.out.println(request.name);
returntrue;
}
// Example Response ModelpublicclassGetSomethingResponse {
publicStringname;
}
// Example Request ModelpublicclassCreateSomethingRequest {
publicStringname;
}
}You can find the current docs on our website. This is a work-in-progress project though so it's not yet complete.
- Passport: A library for adding OAuth2 to authenticate in your Application