vertx / io.vertx.reactivex.ext.web.api.contract / DesignDrivenRouterFactory

DesignDrivenRouterFactory

interface DesignDrivenRouterFactory<Specification : Any>

Main interface for Design Driven Router factory Author: Francesco Guardiani @slinkydeveloper NOTE: This class has been automatically generated from the io.vertx.ext.web.api.contract.DesignDrivenRouterFactory non RX-ified interface using Vert.x codegen.

Functions

addFailureHandler

abstract fun addFailureHandler(method: HttpMethod, path: String, failureHandler: Handler<RoutingContext>): DesignDrivenRouterFactory<Any>

Add a failure handler to a path with a method. If combination path/method is not available in specification, it will throw a io.vertx.reactivex.ext.web.api.contract.RouterFactoryException

addHandler

abstract fun addHandler(method: HttpMethod, path: String, handler: Handler<RoutingContext>): DesignDrivenRouterFactory<Any>

Add an handler to a path with a method. If combination path/method is not available in specification, it will throw a io.vertx.reactivex.ext.web.api.contract.RouterFactoryException

addSecurityHandler

abstract fun addSecurityHandler(securitySchemaName: String, handler: Handler<RoutingContext>): DesignDrivenRouterFactory<Any>

Mount to paths that have to follow a security schema a security handler

enableValidationFailureHandler

abstract fun enableValidationFailureHandler(enable: Boolean): DesignDrivenRouterFactory<Any>

Enable or disable validation failure handler. If you enable it, during router creation it will be mounted a built-in (or custom with function io.vertx.reactivex.ext.web.api.contract.DesignDrivenRouterFactory#setValidationFailureHandler) ValidationException handler as a failure handler. If failure is different from ValidationException, it will be called the next failure handler.

getDelegate

abstract fun getDelegate(): DesignDrivenRouterFactory<Any>

getRouter

abstract fun getRouter(): Router

Construct a new router based on spec. It will fail if you are trying to mount a spec with security schemes without assigned handlers Note: Router is constructed in this function, so it will be respected the path definition ordering.

mountOperationsWithoutHandlers

abstract fun mountOperationsWithoutHandlers(enable: Boolean): DesignDrivenRouterFactory<Any>

Automatic mount handlers that return HTTP 501 status code for operations where you didn't specify an handler.

newInstance

open static fun <Specification : Any> newInstance(arg: DesignDrivenRouterFactory<Any>): DesignDrivenRouterFactory<Specification>
open static fun <Specification : Any> newInstance(arg: DesignDrivenRouterFactory<Any>, __typeArg_Specification: TypeArg<Specification>): DesignDrivenRouterFactory<Specification>

setValidationFailureHandler

abstract fun setValidationFailureHandler(handler: Handler<RoutingContext>): DesignDrivenRouterFactory<Any>

Set default validation failure handler. You can disable this feature from io.vertx.reactivex.ext.web.api.contract.DesignDrivenRouterFactory#enableValidationFailureHandler

Inheritors

OpenAPI3RouterFactory

open class OpenAPI3RouterFactory : DesignDrivenRouterFactory<OpenAPI>

Interface for OpenAPI3RouterFactory. To add an handler, use io.vertx.reactivex.ext.web.api.contract.openapi3.OpenAPI3RouterFactory#addHandlerByOperationId, in this class is better than generic If you want to use remember that you have to pass path as declared in openapi specification Usage example:

OpenAPI3RouterFactory.createRouterFactoryFromFile(vertx, "src/resources/spec.yaml", asyncResult -> { if (!asyncResult.succeeded()) { // IO failure or spec invalid else { OpenAPI3RouterFactory routerFactory = asyncResult.result(); routerFactory.addHandlerByOperationId("operation_id", routingContext -> { // Do something }, routingContext -> { // Do something with failure handler }); Router router = routerFactory.getRouter(); } }); } 
NOTE: This class has been automatically generated from the io.vertx.ext.web.api.contract.openapi3.OpenAPI3RouterFactory non RX-ified interface using Vert.x codegen.