Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract client name lookup to a method #1732

Merged
merged 1 commit into from
Jan 26, 2024
Merged
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 @@ -1061,11 +1061,7 @@ protected NettyOrigin getOrigin(HttpRequestMessage request) {
return null;
}

// make sure the restClientName will never be a raw VIP in cases where it's the fallback for another route
// assignment
String restClientVIP = primaryRoute;
boolean useFullName = context.getBoolean(CommonContextKeys.USE_FULL_VIP_NAME);
String restClientName = useFullName ? restClientVIP : VipUtils.getVIPPrefix(restClientVIP);
String restClientName = getClientName(context);

NettyOrigin origin = null;
// allow implementors to override the origin with custom injection logic
Expand All @@ -1075,7 +1071,7 @@ protected NettyOrigin getOrigin(HttpRequestMessage request) {
origin = getOrCreateOrigin(originManager, overrideOriginName, request.reconstructURI(), context);
} else if (restClientName != null) {
// This is the normal flow - that a RoutingFilter has assigned a route
OriginName originName = OriginName.fromVip(restClientVIP, restClientName);
OriginName originName = OriginName.fromVip(primaryRoute, restClientName);
origin = getOrCreateOrigin(originManager, originName, request.reconstructURI(), context);
}

Expand All @@ -1094,6 +1090,14 @@ protected NettyOrigin getOrigin(HttpRequestMessage request) {
return origin;
}

protected String getClientName(SessionContext context) {
// make sure the restClientName will never be a raw VIP in cases where it's the fallback for another route
// assignment
String restClientVIP = context.getRouteVIP();
boolean useFullName = context.getBoolean(CommonContextKeys.USE_FULL_VIP_NAME);
return useFullName ? restClientVIP : VipUtils.getVIPPrefix(restClientVIP);
}

/**
* Inject your own custom VIP based on your own processing
*
Expand Down
Loading