Handlers-http provides a minimal and adaptable interface for developing web applications on the vert-x3 platform.
Handlers-http is an open webframework for the vert-x3 platform. The middleware layer doesn't depend on any custom classes, so components should be easily inter-changeable with different webframeworks.
Inspired by 'Build You Own Web Framework In Go'
ServerRequestHandlers<Void> handlers = use(
new ExceptionHandler<>(),
new ResponseTimeHandler<>(),
new TimeoutHandler<>(vertx),
(f, n) -> (req, arg) -> {
req.response().end("hello world!");
n.accept(req, arg);
});
var handler = handlers.apply(
(e, a) -> logger.error(a),
(e, a) -> logger.info(a));
server.requestHandler(req -> handler.accept(req, null))
.listen();
public class HandlerImpl implements BiFunction<BiConsumer<HttpServerRequest, Throwable>,
BiConsumer<HttpServerRequest, Void>, BiConsumer<HttpServerRequest, Void>> {
@Override
public BiConsumer<HttpServerRequest, Void> apply(
BiConsumer<HttpServerRequest, Throwable> fail, BiConsumer<HttpServerRequest, Void> next) {
return next;
}
}
- Implementing handler still is quite verbose.
https://github.com/spriet2000/vertx-handlers-http-example
<dependency>
<groupId>com.github.spriet2000</groupId>
<artifactId>vertx-handlers-http</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>