Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.function.BiFunction;

import org.apache.hc.core5.function.Callback;
import org.apache.hc.core5.function.Decorator;
Expand Down Expand Up @@ -95,6 +96,7 @@ public class AsyncServerBootstrap {
private IOSessionListener sessionListener;
private Http1StreamListener streamListener;
private IOReactorMetricsListener threadPoolListener;
private BiFunction<String, URIAuthority, URIAuthority> authorityResolver = RequestRouter.IGNORE_PORT_AUTHORITY_RESOLVER;

private AsyncServerBootstrap() {
this.routeEntries = new ArrayList<>();
Expand Down Expand Up @@ -280,6 +282,17 @@ public final AsyncServerBootstrap setStreamListener(final Http1StreamListener st
return this;
}

/**
* Sets authority resolver to be used when creating the {@link RequestRouter}.
*
* @return this instance.
* @since 5.4
*/
public final AsyncServerBootstrap setAuthorityResolver(final BiFunction<String, URIAuthority, URIAuthority> authorityResolver) {
this.authorityResolver = authorityResolver;
return this;
}

/**
* Registers the given {@link AsyncServerExchangeHandler} {@link Supplier} as a default handler for URIs
* matching the given pattern.
Expand Down Expand Up @@ -453,7 +466,7 @@ public HttpAsyncServer create() {
requestRouterCopy = RequestRouter.create(
new URIAuthority(actualCanonicalHostName),
UriPatternType.URI_PATTERN, routeEntries,
RequestRouter.IGNORE_PORT_AUTHORITY_RESOLVER,
this.authorityResolver,
requestRouter);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.function.BiFunction;

import javax.net.ServerSocketFactory;
import javax.net.ssl.SSLContext;
Expand Down Expand Up @@ -98,6 +99,7 @@ public class ServerBootstrap {
private HttpConnectionFactory<? extends DefaultBHttpServerConnection> connectionFactory;
private ExceptionListener exceptionListener;
private Http1StreamListener streamListener;
private BiFunction<String, URIAuthority, URIAuthority> authorityResolver = RequestRouter.IGNORE_PORT_AUTHORITY_RESOLVER;

private ServerBootstrap() {
this.routeEntries = new ArrayList<>();
Expand Down Expand Up @@ -294,6 +296,17 @@ public final ServerBootstrap setStreamListener(final Http1StreamListener streamL
return this;
}

/**
* Sets authority resolver to be used when creating the {@link RequestRouter}.
*
* @return this instance.
* @since 5.4
*/
public final ServerBootstrap setAuthorityResolver(final BiFunction<String, URIAuthority, URIAuthority> authorityResolver) {
this.authorityResolver = authorityResolver;
return this;
}

/**
* Adds the filter before the filter with the given name.
*/
Expand Down Expand Up @@ -365,7 +378,7 @@ public HttpServer create() {
new URIAuthority(actualCanonicalHostName),
UriPatternType.URI_PATTERN,
routeEntries,
RequestRouter.IGNORE_PORT_AUTHORITY_RESOLVER,
this.authorityResolver,
requestRouter);
}
}
Expand Down
Loading