This port's purpose is to develop HTTP servers (REST services or Web applications). It defines a DSL to declare HTTP request handlers.
Adapters implementing this port are in charge of transforming the DSL into a runtime. And allows you to switch implementations without changing the service.
The /hexagon_web module provides utilities on top of this port for Web application development (like templates helpers).
Install the Dependency¶
This module is not meant to be used directly. You should include and Adapter implementing this feature (as /http_server_jetty) in order to create an HTTP server.
A server is a process listening to HTTP requests on a TCP port.
You can run multiple ones on different ports at the same time (this can be useful to test many microservices at the same time).
The server can be configured with different properties. If you do not provide a value for them, they are searched inside the application settings and lastly, a default value is picked. This is the parameters list:
- banner: informative text shown at start up logs. If not set only runtime information is displayed.
- bindAddress: address to which this process is bound. If none is provided, 127.0.0.1 is taken.
- bindPort: the port which the process listens to. By default, it is 2010.
- contextPath: initial path used for the rest of the routes, by default it is empty.
You can inject an adapter for the Server port using the InjectionManager object: InjectionManager.bindObject
To create a server, you need to provide a router (check the next section for more information), and after creating a server you can run it or stop it with start() and stop() methods.