Class RequestRouter.Builder<T>
- java.lang.Object
-
- org.apache.hc.core5.http.impl.routing.RequestRouter.Builder<T>
-
- Enclosing class:
- RequestRouter<T>
public static class RequestRouter.Builder<T> extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.function.BiFunction<java.lang.String,URIAuthority,URIAuthority>authorityResolverprivate HttpRequestMapper<T>downstreamprivate java.util.List<RequestRouter.Entry<T>>handlerEntriesprivate UriPatternTypepatternType
-
Constructor Summary
Constructors Constructor Description Builder(UriPatternType patternType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RequestRouter.Builder<T>addRoute(java.lang.String hostname, java.lang.String pathPattern, T handler)Adds a route with given hostname and path pattern.RequestRouter.Builder<T>addRoute(URIAuthority authority, java.lang.String pathPattern, T handler)Adds a route with given authority and path pattern.RequestRouter<T>build()RequestRouter.Builder<T>downstream(HttpRequestMapper<T> downstream)Sets a downstream request mapper that can be used as a fallback in case no authoritative service can be found to handle an incoming request.RequestRouter.Builder<T>resolveAuthority(java.util.function.BiFunction<java.lang.String,URIAuthority,URIAuthority> authorityResolver)Sets customURIAuthorityresolutionFunctionthat can be used to normalize or re-write the authority specified in incoming requests prior to request routing.
-
-
-
Field Detail
-
patternType
private final UriPatternType patternType
-
handlerEntries
private final java.util.List<RequestRouter.Entry<T>> handlerEntries
-
authorityResolver
private java.util.function.BiFunction<java.lang.String,URIAuthority,URIAuthority> authorityResolver
-
downstream
private HttpRequestMapper<T> downstream
-
-
Constructor Detail
-
Builder
Builder(UriPatternType patternType)
-
-
Method Detail
-
addRoute
public RequestRouter.Builder<T> addRoute(URIAuthority authority, java.lang.String pathPattern, T handler)
Adds a route with given authority and path pattern. Requests with the same authority and matching the path pattern will be routed for execution to the handler.
-
addRoute
public RequestRouter.Builder<T> addRoute(java.lang.String hostname, java.lang.String pathPattern, T handler)
Adds a route with given hostname and path pattern. Requests with the same hostname and matching the path pattern will be routed for execution to the handler.
-
resolveAuthority
public RequestRouter.Builder<T> resolveAuthority(java.util.function.BiFunction<java.lang.String,URIAuthority,URIAuthority> authorityResolver)
Sets customURIAuthorityresolutionFunctionthat can be used to normalize or re-write the authority specified in incoming requests prior to request routing. The function can return a newURIAuthorityinstance representing an identity of the service authoritative to handle the request ornullif an authoritative service cannot be found or is unknown.
-
downstream
public RequestRouter.Builder<T> downstream(HttpRequestMapper<T> downstream)
Sets a downstream request mapper that can be used as a fallback in case no authoritative service can be found to handle an incoming request. Using this method request mappers can be linked to form a chain of responsibility, with each link representing a different authority.
-
build
public RequestRouter<T> build()
-
-