Browse Source

basePath should always be /contextPath/servletPath/ (the last slash being the location of the eureka dashboard)

fixes gh-101
pull/6/head
Spencer Gibb 10 years ago
parent
commit
7765c721ca
  1. 12
      spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaController.java

12
spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaController.java

@ -11,6 +11,8 @@ import com.netflix.eureka.cluster.PeerEurekaNode; @@ -11,6 +11,8 @@ import com.netflix.eureka.cluster.PeerEurekaNode;
import com.netflix.eureka.resources.StatusResource;
import com.netflix.eureka.util.StatusInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -26,6 +28,9 @@ import java.util.*; @@ -26,6 +28,9 @@ import java.util.*;
@Controller
public class EurekaController {
@Autowired
ServerProperties serverProperties;
@RequestMapping(value = "/", method = RequestMethod.GET)
public String status(HttpServletRequest request, Map<String, Object> model) {
populateBase(request, model);
@ -70,9 +75,10 @@ public class EurekaController { @@ -70,9 +75,10 @@ public class EurekaController {
}
protected void populateBase(HttpServletRequest request, Map<String, Object> model) {
String servletPath = request.getServletPath();
String path = request.getContextPath() + (servletPath==null ? "" : servletPath);
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
String contextPath = serverProperties.getContextPath();
String path = (contextPath == null) ? "" : contextPath + serverProperties.getServletPath();
path = path.replace("//", "/");
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
if (!basePath.endsWith("/")) {
basePath += "/";

Loading…
Cancel
Save