Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MultiTenantHandler

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

Requests that pass the validation will contain a new key in the routing context with the tenant id, for the case of being a default handler the value if this key will be "default".

Hierarchy

  • MultiTenantHandler

Implements

  • any

Index

Properties

Static Readonly TENANT

TENANT: string

The default key used to identify a tenant in the context data.

Methods

addDefaultHandler

  • Add a default handler for the case when no tenant was matched.

    The handler cannot be null.

    Parameters

    Returns MultiTenantHandler

addTenantHandler

  • Add a handler for a given tenant to this handler.

    Both tenant and handler cannot be null.

    Parameters

    Returns MultiTenantHandler

handle

  • Parameters

    Returns void

removeTenant

  • Remove a handler for a given tenant from this handler.

    Tenant cannot be null.

    Parameters

    • tenant: string

    Returns MultiTenantHandler

Static create

  • Create a MultiTenant handler that will extract the tenant id from a given header name.

    Parameters

    • header: string

    Returns MultiTenantHandler

  • Create a MultiTenant handler using a custom tenant extraction function.

    Parameters

    Returns MultiTenantHandler

  • Create a MultiTenant handler using a custom tenant extraction function.

    Parameters

    Returns MultiTenantHandler

Generated using TypeDoc