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
original
non Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<MultiTenantHandler>
__TYPE_ARG
static String
TENANT
The 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 void
accept(RoutingContext item)
MultiTenantHandler
addDefaultHandler(Consumer<RoutingContext> handler)
MultiTenantHandler
addTenantHandler(String tenant, Consumer<RoutingContext> handler)
static MultiTenantHandler
create(String header)
static MultiTenantHandler
create(Function<RoutingContext,String> tenantExtractor)
static MultiTenantHandler
create(Function<RoutingContext,String> tenantExtractor, String contextKey)
boolean
equals(Object o)
io.vertx.ext.web.handler.MultiTenantHandler
getDelegate()
void
handle(RoutingContext arg0)
int
hashCode()
static MultiTenantHandler
newInstance(io.vertx.ext.web.handler.MultiTenantHandler arg)
MultiTenantHandler
removeTenant(String tenant)
String
toString()
-
-
-
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:
handle
in 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:
accept
in interfaceConsumer<RoutingContext>
-
newInstance
public static MultiTenantHandler newInstance(io.vertx.ext.web.handler.MultiTenantHandler arg)
-
-