Package io.vertx.mutiny.ext.web.handler
Class MultiTenantHandler
- java.lang.Object
-
- io.vertx.mutiny.ext.web.handler.MultiTenantHandler
-
- All Implemented Interfaces:
io.vertx.core.Handler<RoutingContext>,Consumer<RoutingContext>
public class MultiTenantHandler extends Object implements io.vertx.core.Handler<RoutingContext>, Consumer<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
originalnon Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<MultiTenantHandler>__TYPE_ARGstatic StringTENANTThe default key used to identify a tenant in the context data.
-
Constructor Summary
Constructors Constructor Description MultiTenantHandler(io.vertx.ext.web.handler.MultiTenantHandler delegate)MultiTenantHandler(Object delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(RoutingContext item)MultiTenantHandleraddDefaultHandler(Consumer<RoutingContext> handler)MultiTenantHandleraddTenantHandler(String tenant, Consumer<RoutingContext> handler)static MultiTenantHandlercreate(String header)static MultiTenantHandlercreate(Function<RoutingContext,String> tenantExtractor)static MultiTenantHandlercreate(Function<RoutingContext,String> tenantExtractor, String contextKey)booleanequals(Object o)io.vertx.ext.web.handler.MultiTenantHandlergetDelegate()voidhandle(RoutingContext arg0)inthashCode()static MultiTenantHandlernewInstance(io.vertx.ext.web.handler.MultiTenantHandler arg)MultiTenantHandlerremoveTenant(String tenant)StringtoString()
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<MultiTenantHandler> __TYPE_ARG
-
TENANT
public static final String TENANT
The default key used to identify a tenant in the context data.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MultiTenantHandler
public MultiTenantHandler(io.vertx.ext.web.handler.MultiTenantHandler delegate)
-
MultiTenantHandler
public MultiTenantHandler(Object delegate)
-
-
Method Detail
-
getDelegate
public io.vertx.ext.web.handler.MultiTenantHandler getDelegate()
-
handle
public void handle(RoutingContext arg0)
- Specified by:
handlein interfaceio.vertx.core.Handler<RoutingContext>
-
create
public static MultiTenantHandler create(String header)
- Parameters:
header- the header to lookup (e.g.: "X-Tenant")- Returns:
- the new handler.
-
create
public static MultiTenantHandler create(Function<RoutingContext,String> tenantExtractor)
- 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)
- 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
public MultiTenantHandler addTenantHandler(String tenant, Consumer<RoutingContext> handler)
- Parameters:
tenant- the tenant idhandler- the handler to register.- Returns:
-
removeTenant
public MultiTenantHandler removeTenant(String tenant)
- Parameters:
tenant- the tenant id- Returns:
- a fluent reference to self.
-
addDefaultHandler
public MultiTenantHandler addDefaultHandler(Consumer<RoutingContext> handler)
- Parameters:
handler- the handler to register.- Returns:
-
accept
public void accept(RoutingContext item)
- Specified by:
acceptin interfaceConsumer<RoutingContext>
-
newInstance
public static MultiTenantHandler newInstance(io.vertx.ext.web.handler.MultiTenantHandler arg)
-
-