Module io.inverno.mod.http.server


module io.inverno.mod.http.server

The Inverno framework HTTP server module provides a HTTP1.x and HTTP/2 server.

It defines the following sockets:

configuration
the HTTP server module configuration
netService (required)
the Net service used to create the HTTP server
reactor (required)
the Reactor
resourceService (required)
the resource service used to load resources required by the HTTP server (eg. key store...)
controller
override the default HTTP server controller used to process server exchanges
headerCodecs
custom header codecs
parameterConverter
override the default parameter converter used in Parameter instances to convert their values

It exposes the following beans:

configuration
the HTTP server module configuration
controller
the HTTP server controller

A simple HTTP server using the default configuration can be started as follows:


 NetService netService = ...
 Reactor reactor = ...
 ResourceService resourceService = ...

 Application.with(new Server.Builder(netService, reactor, resourceService)
     .setConfiguration(HttpServerConfigurationLoader.load(conf -> conf.server_port(8080)))
     .setController(ServerController.from(
         exchange -> exchange
             .response()
             .body()
             .raw()
             .value(Unpooled.unreleasableBuffer(Unpooled.copiedBuffer("Hello, world!", Charsets.DEFAULT)))
      ))
 ).run();
 

Note that in above example, all requests sent to the server are processed with the same handler, the io.inverno.mod.web.server is better suited to route requests based on gRPC service and method names. It is recommended to rely on a protoc plugin for generating a proper gRPC Web routes configurer from Protocol buffer definitions.

Since:
1.0
Author:
Jeremy Kuhn