org.apache.hc.core5.http.impl.routing

## Class RequestRouter<T>

- java.lang.Object
- - org.apache.hc.core5.http.impl.routing.RequestRouter<T>

- Type Parameters:
    `T` - request handler type.
  All Implemented Interfaces:
    HttpRequestMapper<T>

      @Contract(threading=IMMUTABLE)
      public class RequestRouter<T>
      extends Object
      implements HttpRequestMapper<T>

  Request mapper that can route requests based on their properties to a specific request handler.
  Since:
    5.3

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `RequestRouter.Builder<T>`
    `static class` | `RequestRouter.Entry<T>`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static BiFunction<String,URIAuthority,URIAuthority>` | `IGNORE_PORT_AUTHORITY_RESOLVER`
    `static URIAuthority` | `LOCAL_AUTHORITY`
    `static BiFunction<String,URIAuthority,URIAuthority>` | `LOCAL_AUTHORITY_RESOLVER`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T> RequestRouter.Builder<T>` | `builder()`
    `static <T> RequestRouter.Builder<T>` | `builder(UriPatternType patternType)`
    `static <T> RequestRouter<T>` | `create(URIAuthority primaryAuthority, UriPatternType patternType, List<RequestRouter.Entry<T>> handlerEntries, BiFunction<String,URIAuthority,URIAuthority> authorityResolver, HttpRequestMapper<T> downstream)`
    `T` | `resolve(HttpRequest request, HttpContext context)` Resolves a handler matching the given request.

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### LOCAL_AUTHORITY

          public static final URIAuthority LOCAL_AUTHORITY

    - #### LOCAL_AUTHORITY_RESOLVER

          public static final BiFunction<String,URIAuthority,URIAuthority> LOCAL_AUTHORITY_RESOLVER

    - #### IGNORE_PORT_AUTHORITY_RESOLVER

          public static final BiFunction<String,URIAuthority,URIAuthority> IGNORE_PORT_AUTHORITY_RESOLVER

  - ### Method Detail

    - #### create

          @Internal
          public static <T> RequestRouter<T> create(URIAuthority primaryAuthority,
                                                              UriPatternType patternType,
                                                              List<RequestRouter.Entry<T>> handlerEntries,
                                                              BiFunction<String,URIAuthority,URIAuthority> authorityResolver,
                                                              HttpRequestMapper<T> downstream)

    - #### builder

          public static <T> RequestRouter.Builder<T> builder(UriPatternType patternType)

    - #### builder

          public static <T> RequestRouter.Builder<T> builder()

    - #### resolve

          public T resolve(HttpRequest request,
                           HttpContext context)
                    throws HttpException

      Description copied from interface: `HttpRequestMapper`
      Resolves a handler matching the given request.
      Specified by:
        `resolve` in interface `HttpRequestMapper<T>`
      Parameters:
        `request` - the request to map to a handler
      Returns:
        HTTP request handler or `null` if no match is found.
      Throws:
        `HttpException` - in case of an HTTP protocol violation.

Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.