Package dev.relism.flash.extension
Interface FlashApplication
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
One application's complete contribution to a
FlashApp — its routes, extensions and
services — expressed independently of which port or configuration it runs on.
Optional. The fluent form keeps working exactly as before; this interface exists so the same application can be created more than once, on more than one port:
public final class BlogApp implements FlashApplication {
@Override public void configure(FlashApp app) {
app.install(new JacksonExtension());
app.mount("/api", scope -> scope.scan("dev.blog.api"));
app.ws("/live", new FeedSocket());
}
}
// production
FlashApp.create(8080).apply(new BlogApp()).startAndBlock();
It takes FlashApp rather than FlashRegistrar deliberately: ws and
mount live on FlashApp, and an application that could not register a
WebSocket route or a mounted namespace would be a half-application.
Being a @FunctionalInterface, a lambda and a named class are the same thing here —
app -> app.get("/ping", ...) is as valid as new BlogApp().
- See Also:
-
Method Summary
-
Method Details
-
configure
Registers this application ontoapp. Called immediately byFlashApp.apply(dev.relism.flash.extension.FlashApplication), so the service graph is still open for declarations (app.ctx().supply(...)) and the listener is already bound (app.port()).
-