Package kos.core

Class SimplifiedRouter

  • All Implemented Interfaces:
    io.vertx.core.Handler<io.vertx.core.http.HttpServerRequest>

    public class SimplifiedRouter
    extends Object
    implements io.vertx.core.Handler<io.vertx.core.http.HttpServerRequest>
    Small layer over Router that aims to simplify a few common aspects regarding route configuration, like intercepting requests and the reading body requests in a POST, PUT and PATCH requests.
    • Field Detail

      • log

        private static final io.vertx.core.logging.Logger log
      • router

        private final io.vertx.ext.web.Router router
      • httpMethodsThatMayReadBody

        private final Map<io.vertx.core.http.HttpMethod,​Boolean> httpMethodsThatMayReadBody
    • Constructor Detail

      • SimplifiedRouter

        public SimplifiedRouter​(io.vertx.ext.web.Router router,
                                Map<io.vertx.core.http.HttpMethod,​Boolean> httpMethodsThatMayReadBody)
      • SimplifiedRouter

        private SimplifiedRouter​(io.vertx.ext.web.Router router,
                                 RequestInterceptorHandler interceptor,
                                 Map<io.vertx.core.http.HttpMethod,​Boolean> httpMethodsThatMayReadBody)
    • Method Detail

      • unwrap

        public io.vertx.ext.web.Router unwrap()
        Returns the wrapped Vert.x Router.
        Returns:
        the wrapped Vert.x Router
      • intercept

        public void intercept​(RequestInterceptor interceptor)
        Registers a Handler to intercept all requests.
        Parameters:
        interceptor - the interceptor handler.
      • route

        public void route​(io.vertx.core.http.HttpMethod method,
                          String path,
                          RequestHandler handler)
        Routes requests made to path to a particular handler.
        Parameters:
        method - Http Method used by this endpoint
        path - relative URI used by this endpoint
        handler - request handler
      • route

        public void route​(io.vertx.core.http.HttpMethod method,
                          String path,
                          io.vertx.core.Handler<io.vertx.ext.web.RoutingContext> handler)
        Routes requests made to path to a particular handler.
        Parameters:
        method - Http Method used by this endpoint
        path - relative URI used by this endpoint
        handler - request handler
      • wrapWithAutoBodyReader

        public static SimplifiedRouter wrapWithAutoBodyReader​(io.vertx.ext.web.Router router)
        Creates an instance of SimplifiedRouter that will automatically read the request body payload for PATCH, POST and PUT.
        Parameters:
        router - the router instance that will be wrapped
        Returns:
        An instance of SimplifiedRouter
      • wrapWithNoAuthBodyReader

        public static SimplifiedRouter wrapWithNoAuthBodyReader​(io.vertx.ext.web.Router router)
        Creates a basic instance of SimplifiedRouter. Developers that use routers created by this method should configure themselves how to read the request body payload.
        Parameters:
        router - the router instance that will be wrapped
        Returns:
        An instance of SimplifiedRouter
      • handle

        public void handle​(io.vertx.core.http.HttpServerRequest event)
        Specified by:
        handle in interface io.vertx.core.Handler<io.vertx.core.http.HttpServerRequest>