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 io.vertx.core.Future<RouterBuilder> |
create(io.vertx.core.Vertx vertx,
String url)
Create a new
RouterBuilder |
static void |
create(io.vertx.core.Vertx vertx,
String url,
io.vertx.core.Handler<io.vertx.core.AsyncResult<RouterBuilder>> handler)
Like
this#create(Vertx, String) |
static io.vertx.core.Future<RouterBuilder> |
create(io.vertx.core.Vertx vertx,
String url,
OpenAPILoaderOptions options)
Create a new
RouterBuilder |
static void |
create(io.vertx.core.Vertx vertx,
String url,
OpenAPILoaderOptions options,
io.vertx.core.Handler<io.vertx.core.AsyncResult<RouterBuilder>> handler)
Like
this#create(Vertx, String, OpenAPILoaderOptions) |
Router |
createRouter()
Construct a new router based on spec.
|
OpenAPIHolder |
getOpenAPI() |
RouterBuilderOptions |
getOptions() |
io.vertx.json.schema.SchemaParser |
getSchemaParser() |
io.vertx.json.schema.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(io.vertx.core.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(Function<RoutingContext,io.vertx.core.json.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(io.vertx.core.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
sio.vertx.json.schema.SchemaRouter getSchemaRouter()
Schema
instancesio.vertx.json.schema.SchemaParser getSchemaParser()
Schema
RouterBuilder serviceExtraPayloadMapper(Function<RoutingContext,io.vertx.core.json.JsonObject> serviceExtraPayloadMapper)
ServiceRequest
serviceExtraPayloadMapper
- Router createRouter()
static io.vertx.core.Future<RouterBuilder> create(io.vertx.core.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(io.vertx.core.Vertx vertx, String url, io.vertx.core.Handler<io.vertx.core.AsyncResult<RouterBuilder>> handler)
this#create(Vertx, String)
static io.vertx.core.Future<RouterBuilder> create(io.vertx.core.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(io.vertx.core.Vertx vertx, String url, OpenAPILoaderOptions options, io.vertx.core.Handler<io.vertx.core.AsyncResult<RouterBuilder>> handler)
this#create(Vertx, String, OpenAPILoaderOptions)
Copyright © 2020 Eclipse. All rights reserved.