public interface RouterBuilder
Router
from an OpenAPI 3 contract. operation(String)
(String, Handler)}
RouterBuilder.create(vertx, "src/resources/spec.yaml", asyncResult -> {
if (!asyncResult.succeeded()) {
// IO failure or spec invalid
} else {
RouterBuilder routerBuilder = asyncResult.result();
RouterBuilder.operation("operation_id").handler(routingContext -> {
// Do something
}, routingContext -> {
// Do something with failure handler
});
Router router = routerBuilder.createRouter();
}
});
this#bodyHandler(BodyHandler)
this#rootHandler(Handler)
Modifier and Type | Method and Description |
---|---|
default RouterBuilder |
bodyHandler(BodyHandler bodyHandler)
Deprecated.
Use
rootHandler(Handler) instead. The order matters, so adding the body handler should
happen after any PLATFORM or SECURITY_POLICY handler(s). |
static Future<RouterBuilder> |
create(Vertx vertx,
String url)
Create a new
RouterBuilder |
static void |
create(Vertx vertx,
String url,
Handler<AsyncResult<RouterBuilder>> handler)
Like
this#create(Vertx, String) |
static Future<RouterBuilder> |
create(Vertx vertx,
String url,
OpenAPILoaderOptions options)
Create a new
RouterBuilder |
static void |
create(Vertx vertx,
String url,
OpenAPILoaderOptions options,
Handler<AsyncResult<RouterBuilder>> handler)
Like
this#create(Vertx, String, OpenAPILoaderOptions) |
Router |
createRouter()
Construct a new router based on spec.
|
OpenAPIHolder |
getOpenAPI() |
RouterBuilderOptions |
getOptions() |
SchemaParser |
getSchemaParser()
Deprecated.
This method exposes the internal of the OpenAPI handler, it will be removed in the future. Users should
configure the json schema module from the options.
|
SchemaRouter |
getSchemaRouter()
Deprecated.
This method exposes the internal of the OpenAPI handler, it will be removed in the future. Users should
configure the json schema module from the options.
|
RouterBuilder |
mountServiceInterface(Class interfaceClass,
String address)
Introspect the Web Api Service interface to route to service all matching method names with operation ids.
|
RouterBuilder |
mountServicesFromExtensions()
Introspect the OpenAPI spec to mount handlers for all operations that specifies a x-vertx-event-bus annotation.
|
Operation |
operation(String operationId)
Access to an operation defined in the contract with
operationId |
List<Operation> |
operations() |
RouterBuilder |
rootHandler(Handler<RoutingContext> rootHandler)
Add global handler to be applied prior to
Router being generated. |
SecurityScheme |
securityHandler(String securitySchemeName)
Creates a new security scheme for the required
AuthenticationHandler . |
RouterBuilder |
securityHandler(String securitySchemeName,
AuthenticationHandler handler)
Mount to paths that have to follow a security schema a security handler.
|
RouterBuilder |
serviceExtraPayloadMapper(java.util.function.Function<RoutingContext,JsonObject> serviceExtraPayloadMapper)
When set, this function is called while creating the payload of
ServiceRequest |
RouterBuilder |
setOptions(RouterBuilderOptions options)
Set options of router builder.
|
Operation operation(String operationId)
operationId
operationId
- the id of the operationIllegalArgumentException
- if the operation id doesn't exist in the contract@Deprecated default RouterBuilder bodyHandler(BodyHandler bodyHandler)
rootHandler(Handler)
instead. The order matters, so adding the body handler should
happen after any PLATFORM
or SECURITY_POLICY
handler(s).bodyHandler
- RouterBuilder rootHandler(Handler<RoutingContext> rootHandler)
Router
being generated. bodyHandler(BodyHandler)
rootHandler
- RouterBuilder securityHandler(String securitySchemeName, AuthenticationHandler handler)
securitySchemeName
is present in the OpenAPI document.
For must use cases the method securityHandler(String)
should be used.securitySchemeName
- the components security scheme idhandler
- the authentication handlerRouterBuilder mountServicesFromExtensions()
RouterBuilder mountServiceInterface(Class interfaceClass, String address)
RouterBuilder setOptions(RouterBuilderOptions options)
RouterBuilderOptions
options
- RouterBuilderOptions getOptions()
RouterBuilderOptions
OpenAPIHolder getOpenAPI()
$ref
s@Deprecated SchemaRouter getSchemaRouter()
Schema
instances@Deprecated SchemaParser getSchemaParser()
Schema
RouterBuilder serviceExtraPayloadMapper(java.util.function.Function<RoutingContext,JsonObject> serviceExtraPayloadMapper)
ServiceRequest
serviceExtraPayloadMapper
- SecurityScheme securityHandler(String securitySchemeName)
AuthenticationHandler
.Router createRouter()
static Future<RouterBuilder> create(Vertx vertx, String url)
RouterBuilder
vertx
- url
- location of your spec. It can be an absolute path, a local path or remote url (with HTTP/HTTPS
protocol)static void create(Vertx vertx, String url, Handler<AsyncResult<RouterBuilder>> handler)
this#create(Vertx, String)
static Future<RouterBuilder> create(Vertx vertx, String url, OpenAPILoaderOptions options)
RouterBuilder
vertx
- url
- location of your spec. It can be an absolute path, a local path or remote url (with HTTP/HTTPS
protocol)options
- options for specification loadingstatic void create(Vertx vertx, String url, OpenAPILoaderOptions options, Handler<AsyncResult<RouterBuilder>> handler)
this#create(Vertx, String, OpenAPILoaderOptions)
Copyright © 2023 Eclipse. All rights reserved.