Skip to content

Commit

Permalink
correct determination of routing protocol in zuul filter
Browse files Browse the repository at this point in the history
  • Loading branch information
AO-StreetArt committed Dec 12, 2018
1 parent ffeee79 commit 97ac396
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/java/com/ao/adrestia/filters/RoutingFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,17 @@ public Object run() {
}
}

// Determine the protocol of the request
String originalUrl = context.getRequest().getRequestURL().toString();
String[] originalUrlSplitList = originalUrl.split(":", 1);
String routedProtocol = "";
if (originalUrlSplitList.length > 0) {
routedProtocol = originalUrlSplitList[0];
}
try {
// Set the URL of the request to a new URL with the existing protocol
log.info("Returning final URL {}://{}:{}/{}", currentUrl.getProtocol(), hostname, port, newTail);
context.setRouteHost(new URL(currentUrl.getProtocol(), hostname, port, ""));
log.info("Returning final URL {}://{}:{}/{}", routedProtocol, hostname, port, newTail);
context.setRouteHost(new URL(routedProtocol, hostname, port, ""));
context.put("requestURI", newTail);
} catch (Exception e) {
log.error("Error setting service URL", e);
Expand Down

0 comments on commit 97ac396

Please sign in to comment.