Class MultiTenantHandler
java.lang.Object
io.vertx.rxjava3.ext.web.handler.MultiTenantHandler
- All Implemented Interfaces:
Handler<RoutingContext>, io.vertx.lang.rx.RxDelegate
public class MultiTenantHandler
extends Object
implements io.vertx.lang.rx.RxDelegate, Handler<RoutingContext>
A handler which selectively executes another handler if a precondition is met.
There are cases where applications are build as multi tenant, in this cases one of the
common tasks is to configure different authentication mechanisms for each tenant.
This handler will allow registering any other handler and will only execute it if
the precondition is met. There are 2 way of defining a precondition:
- A http header value for example
X-Tenant
- A custom extractor function that can return a String from the context
NOTE: This class has been automatically generated from the original non RX-ified interface using Vert.x codegen.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final io.vertx.lang.rx.TypeArg<MultiTenantHandler> static final StringThe default key used to identify a tenant in the context data. -
Constructor Summary
ConstructorsConstructorDescriptionMultiTenantHandler(MultiTenantHandler delegate) MultiTenantHandler(Object delegate) -
Method Summary
Modifier and TypeMethodDescriptionaddDefaultHandler(Handler<RoutingContext> handler) Add a default handler for the case when no tenant was matched.addTenantHandler(String tenant, Handler<RoutingContext> handler) Add a handler for a given tenant to this handler.static MultiTenantHandlerCreate a MultiTenant handler that will extract the tenant id from a given header name.static MultiTenantHandlercreate(Function<RoutingContext, String> tenantExtractor) Create a MultiTenant handler using a custom tenant extraction function.static MultiTenantHandlercreate(Function<RoutingContext, String> tenantExtractor, String contextKey) Create a MultiTenant handler using a custom tenant extraction function.booleanvoidhandle(RoutingContext event) Something has happened, so handle it.inthashCode()static MultiTenantHandlerremoveTenant(String tenant) Remove a handler for a given tenant from this handler.toString()
-
Field Details
-
__TYPE_ARG
-
TENANT
The default key used to identify a tenant in the context data.- See Also:
-
-
Constructor Details
-
MultiTenantHandler
-
MultiTenantHandler
-
-
Method Details
-
toString
-
equals
-
hashCode
-
getDelegate
- Specified by:
getDelegatein interfaceio.vertx.lang.rx.RxDelegate
-
handle
Something has happened, so handle it.- Specified by:
handlein interfaceHandler<RoutingContext>- Parameters:
event- the event to handle
-
create
Create a MultiTenant handler that will extract the tenant id from a given header name.- Parameters:
header- the header to lookup (e.g.: "X-Tenant")- Returns:
- the new handler.
-
create
Create a MultiTenant handler using a custom tenant extraction function.- Parameters:
tenantExtractor- the function that extracts the tenant id from the request- Returns:
- the new handler.
-
create
public static MultiTenantHandler create(Function<RoutingContext, String> tenantExtractor, String contextKey) Create a MultiTenant handler using a custom tenant extraction function.- Parameters:
tenantExtractor- the function that extracts the tenant id from the requestcontextKey- the custom key to store the tenant id in the context- Returns:
- the new handler.
-
addTenantHandler
Add a handler for a given tenant to this handler. Both tenant and handler cannot be null.- Parameters:
tenant- the tenant idhandler- the handler to register.- Returns:
- a fluent reference to self.
-
removeTenant
Remove a handler for a given tenant from this handler. Tenant cannot be null.- Parameters:
tenant- the tenant id- Returns:
- a fluent reference to self.
-
addDefaultHandler
Add a default handler for the case when no tenant was matched. The handler cannot be null.- Parameters:
handler- the handler to register.- Returns:
- a fluent reference to self.
-
newInstance
-