Class HttpHeaderTenantResolver
java.lang.Object
io.micronaut.multitenancy.tenantresolver.HttpHeaderTenantResolver
- All Implemented Interfaces:
HttpRequestTenantResolver
,TenantResolver
@Singleton
@Requires(beans=HttpHeaderTenantResolverConfiguration.class) @Requires(property="micronaut.multitenancy.tenantresolver.httpheader.enabled",value="true",defaultValue="false")
public class HttpHeaderTenantResolver
extends Object
implements TenantResolver, HttpRequestTenantResolver
A
TenantResolver
that resolves the tenant from the request HTTP Header.- Since:
- 1.0.0
- Author:
- Sergio del Amo
-
Field Summary
Fields inherited from interface io.micronaut.multitenancy.tenantresolver.TenantResolver
ALL, DEFAULT, PREFIX
-
Constructor Summary
ConstructorDescriptionHttpHeaderTenantResolver
(HttpHeaderTenantResolverConfiguration configuration) -
Method Summary
Modifier and TypeMethodDescription@NonNull Serializable
Resolves the current tenant identifier.@NonNull Serializable
resolveTenantIdentifier
(@NonNull io.micronaut.http.HttpRequest<?> request) Resolves the current tenant identifier.
-
Field Details
-
headerName
The name of the header.
-
-
Constructor Details
-
HttpHeaderTenantResolver
- Parameters:
configuration
-HttpHeaderTenantResolverConfiguration
configuration
-
-
Method Details
-
resolveTenantIdentifier
Description copied from interface:TenantResolver
Resolves the current tenant identifier.
In a Multi Tenant setup where a single database is being used amongst multiple tenants this would be the object that is used as the tenantId property for each domain class.
- Specified by:
resolveTenantIdentifier
in interfaceTenantResolver
- Returns:
- the tenant ID if resolved.
- Throws:
TenantNotFoundException
- if tenant not found
-
resolveTenantIdentifier
@NonNull public @NonNull Serializable resolveTenantIdentifier(@NonNull @NonNull io.micronaut.http.HttpRequest<?> request) throws TenantNotFoundException Description copied from interface:HttpRequestTenantResolver
Resolves the current tenant identifier.- Specified by:
resolveTenantIdentifier
in interfaceHttpRequestTenantResolver
- Parameters:
request
- The HTTP request- Returns:
- The tenant identifier
- Throws:
TenantNotFoundException
- if tenant not found
-