The Web Framework combines multiple JavaWebStack libraries with glue code and helpers to allow fast web development
class MyWebApp extends WebApplication {
protected void setupConfig(Config config) {
config.addEnvFile(".env");
}
protected void setupModels(SQL sql) throws ORMConfigurationException {
}
protected void setupServer(HTTPServer server) {
server.get("/", exchange -> {
return "Hello World";
});
server.controller(new ExampleController());
}
}
// Example Controller
@PathPrefix("/api/v1")
public class ExampleController extends HttpController {
@Get("/{name}")
public GetSomethingResponse getSomething(@Path("name") String name) {
GetSomethingResponse response = new GetSomethingResponse();
response.name = name;
// Automatically Serializes it to JSON if Accept header is not set.
return response;
}
@Post // If empty it uses the /api/v1 route
public boolean createSomething(@Body CreateSomethingRequest request) {
// @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);
return true;
}
// Example Response Model
public class GetSomethingResponse {
public String name;
}
// Example Request Model
public class CreateSomethingRequest {
public String name;
}
}
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