io.vertx.rxjava.ext.web.handler

## Class MultiTenantHandler

- java.lang.Object
- - io.vertx.rxjava.ext.web.handler.MultiTenantHandler

- All Implemented Interfaces:
    Handler<RoutingContext>, PlatformHandler

      public class MultiTenantHandler
      extends Object
      implements PlatformHandler, 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
  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".

  NOTE: This class has been automatically generated from the `original` non RX-ified interface using Vert.x codegen.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static io.vertx.lang.rx.TypeArg<MultiTenantHandler>` | `__TYPE_ARG`
    `static String` | `TENANT` The default key used to identify a tenant in the context data.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MultiTenantHandler(MultiTenantHandler delegate)`
    `MultiTenantHandler(Object delegate)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `MultiTenantHandler` | `addDefaultHandler(Handler<RoutingContext> handler)` Add a default handler for the case when no tenant was matched.
    `MultiTenantHandler` | `addTenantHandler(String tenant, Handler<RoutingContext> handler)` Add a handler for a given tenant to this handler.
    `static MultiTenantHandler` | `create(java.util.function.Function<RoutingContext,String> tenantExtractor)` Create a MultiTenant handler using a custom tenant extraction function.
    `static MultiTenantHandler` | `create(java.util.function.Function<RoutingContext,String> tenantExtractor, String contextKey)` Create a MultiTenant handler using a custom tenant extraction function.
    `static MultiTenantHandler` | `create(String header)` Create a MultiTenant handler that will extract the tenant id from a given header name.
    `boolean` | `equals(Object o)`
    `MultiTenantHandler` | `getDelegate()`
    `void` | `handle(RoutingContext event)` Something has happened, so handle it.
    `int` | `hashCode()`
    `static MultiTenantHandler` | `newInstance(MultiTenantHandler arg)`
    `MultiTenantHandler` | `removeTenant(String tenant)` Remove a handler for a given tenant from this handler.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface io.vertx.rxjava.ext.web.handler.PlatformHandler

      `newInstance`

- - ### Field Detail

    - #### __TYPE_ARG

          public static final io.vertx.lang.rx.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(MultiTenantHandler delegate)

    - #### MultiTenantHandler

          public MultiTenantHandler(Object delegate)

  - ### Method Detail

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### getDelegate

          public MultiTenantHandler getDelegate()

      Specified by:
        `getDelegate` in interface `PlatformHandler`

    - #### handle

          public void handle(RoutingContext event)

      Something has happened, so handle it.
      Specified by:
        `handle` in interface `Handler<RoutingContext>`
      Specified by:
        `handle` in interface `PlatformHandler`
      Parameters:
        `event` - the event to handle

    - #### create

          public static MultiTenantHandler create(String header)

      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

          public static MultiTenantHandler create(java.util.function.Function<RoutingContext,String> tenantExtractor)

      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(java.util.function.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 request
        `contextKey` - the custom key to store the tenant id in the context
      Returns:
        the new handler.

    - #### addTenantHandler

          public MultiTenantHandler addTenantHandler(String tenant,
                                                     Handler<RoutingContext> handler)

      Add a handler for a given tenant to this handler. Both tenant and handler cannot be null.
      Parameters:
        `tenant` - the tenant id
        `handler` - the handler to register.
      Returns:
        a fluent reference to self.

    - #### removeTenant

          public MultiTenantHandler removeTenant(String tenant)

      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

          public MultiTenantHandler addDefaultHandler(Handler<RoutingContext> handler)

      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

          public static MultiTenantHandler newInstance(MultiTenantHandler arg)

Copyright © 2022 Eclipse. All rights reserved.