Skip to content
Open
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 @@ -74,6 +74,12 @@ public class KafkaRestConfig extends RestConfig {
+ " hostname is used";
public static final String HOST_NAME_DEFAULT = "";

public static final String HOST_PORT_CONFIG = "host.port";
private static final String HOST_PORT_DOC =
"The host port used to generate absolute URLs in responses. If empty, the default canonical"
+ " port is used";
public static final String HOST_PORT_DEFAULT = "-1";

public static final String ADVERTISED_LISTENERS_CONFIG = "advertised.listeners";
protected static final String ADVERTISED_LISTENERS_DOC =
"List of advertised listeners. Used when generating absolute URLs in responses. Protocols"
Expand Down Expand Up @@ -376,6 +382,12 @@ protected static ConfigDef baseKafkaRestConfigDef() {
HOST_NAME_DEFAULT,
Importance.MEDIUM, HOST_NAME_DOC
)
.define(
HOST_PORT_CONFIG,
Type.INT,
HOST_PORT_DEFAULT,
Importance.MEDIUM, HOST_PORT_DOC
)
.define(
ADVERTISED_LISTENERS_CONFIG,
Type.LIST,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ public static UriBuilder absoluteUriBuilder(KafkaRestConfig config, UriInfo uriI
URI origAbsoluteUri = uriInfo.getAbsolutePath();
builder.scheme(origAbsoluteUri.getScheme());
// Only reset the port if it was set in the original URI
if (origAbsoluteUri.getPort() != -1) {
Integer port = config.getInt(KafkaRestConfig.HOST_PORT_CONFIG);
if (port != null && port != -1) {
builder.port(port);
} else if (origAbsoluteUri.getPort() != -1) {
try {
builder.port(config.consumerPort(origAbsoluteUri.getScheme()));
} catch (URISyntaxException e) {
Expand Down