In webflux world, it is easy to create a HttpHandler adapter to connect the underlay Web server, thus it is easy to start up an embedded web server based application without Spring Boot, eg.
@Bean
@Profile("default")
public HttpServer httpServer(ApplicationContext context) {
HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build();
ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
return HttpServer.create()
.host("localhost")
.port(this.port)
.handle(adapter);
}
If possible providing such an API to simplify the Servlet stack, hide the configuration of WebApplicationInitializer
, and allow developer create an embedded server programmatically to serve the application and package the application in a jar package.
Comment From: rstoyanchev
HttpHandler
does not remove the need to use WebApplicationInitializer
. It abstracts only the handling of an HTTP request but you still need to deploy it accordingly. In the case of Servlet containers, HttpHandler
is adapted to a Servlet
, which you then need to deploy in all the usual ways.
Comment From: hantsy
@rstoyanchev I think you mistook my meanings. What I expected is creating(or porting) the existing webflux HttpHandler
and HttpHandlerAdapter
equivalent APIs for Servlet stack (and simplify/hide the config of WebApplicationInitializer
for DispatchServlet
).