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 |
---|---|
RouterBuilder |
bodyHandler(BodyHandler bodyHandler)
Supply your own BodyHandler if you would like to control body limit, uploads directory and deletion of uploaded
files.
|
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() |
SchemaRouter |
getSchemaRouter() |
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. |
RouterBuilder |
securityHandler(String securitySchemaName,
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 contractRouterBuilder bodyHandler(BodyHandler bodyHandler)
bodyHandler
- RouterBuilder rootHandler(Handler<RoutingContext> rootHandler)
Router
being generated. bodyHandler(BodyHandler)
rootHandler
- RouterBuilder securityHandler(String securitySchemaName, AuthenticationHandler handler)
securitySchemaName
- handler
- RouterBuilder mountServicesFromExtensions()
RouterBuilder mountServiceInterface(Class interfaceClass, String address)
RouterBuilder setOptions(RouterBuilderOptions options)
RouterBuilderOptions
options
- RouterBuilderOptions getOptions()
RouterBuilderOptions
OpenAPIHolder getOpenAPI()
$ref
sSchemaRouter getSchemaRouter()
Schema
instancesSchemaParser getSchemaParser()
Schema
RouterBuilder serviceExtraPayloadMapper(java.util.function.Function<RoutingContext,JsonObject> serviceExtraPayloadMapper)
ServiceRequest
serviceExtraPayloadMapper
- 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 © 2021 Eclipse. All rights reserved.