Commit 5055b46e by Dave Syer

Change default eureka path

/v2/* -> /eureka/api/* The prefix can't be /eureka because we use that for static resources. Note that the "api" prefix gets passed to the Jersey resources as a "version" (and defaults to "v2" when it can't be parsed). Fixes gh-41
parent 9e142bf7
...@@ -21,10 +21,10 @@ import java.util.HashMap; ...@@ -21,10 +21,10 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.boot.context.properties.ConfigurationProperties;
import lombok.Data; import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import com.netflix.discovery.EurekaClientConfig; import com.netflix.discovery.EurekaClientConfig;
/** /**
...@@ -35,6 +35,8 @@ import com.netflix.discovery.EurekaClientConfig; ...@@ -35,6 +35,8 @@ import com.netflix.discovery.EurekaClientConfig;
@ConfigurationProperties("eureka.client") @ConfigurationProperties("eureka.client")
public class EurekaClientConfigBean implements EurekaClientConfig { public class EurekaClientConfigBean implements EurekaClientConfig {
public static final String DEFAULT_URL = "http://localhost:8761" + EurekaServerConfigBean.DEFAULT_PATH + "/";
public static final String DEFAULT_ZONE = "defaultZone"; public static final String DEFAULT_ZONE = "defaultZone";
private static final int MINUTES = 60; private static final int MINUTES = 60;
...@@ -82,7 +84,7 @@ public class EurekaClientConfigBean implements EurekaClientConfig { ...@@ -82,7 +84,7 @@ public class EurekaClientConfigBean implements EurekaClientConfig {
private Map<String,String> serviceUrl = new HashMap<String, String>(); private Map<String,String> serviceUrl = new HashMap<String, String>();
{ {
serviceUrl.put(DEFAULT_ZONE, "http://localhost:8761/v2/"); serviceUrl.put(DEFAULT_ZONE, DEFAULT_URL);
} }
private boolean gZipContent = true; private boolean gZipContent = true;
......
...@@ -33,6 +33,10 @@ import com.netflix.eureka.EurekaServerConfig; ...@@ -33,6 +33,10 @@ import com.netflix.eureka.EurekaServerConfig;
@ConfigurationProperties("eureka.server") @ConfigurationProperties("eureka.server")
public class EurekaServerConfigBean implements EurekaServerConfig { public class EurekaServerConfigBean implements EurekaServerConfig {
public static final String DEFAULT_PREFIX = "/eureka";
public static final String DEFAULT_PATH = DEFAULT_PREFIX + "/api";
private static final int MINUTES = 60 * 1000; private static final int MINUTES = 60 * 1000;
private String aWSAccessId; private String aWSAccessId;
......
...@@ -5,6 +5,7 @@ import javax.servlet.Filter; ...@@ -5,6 +5,7 @@ import javax.servlet.Filter;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.embedded.FilterRegistrationBean; import org.springframework.boot.context.embedded.FilterRegistrationBean;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient; import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.eureka.EurekaServerConfigBean;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
...@@ -36,8 +37,8 @@ public class EurekaServerConfiguration extends WebMvcConfigurerAdapter { ...@@ -36,8 +37,8 @@ public class EurekaServerConfiguration extends WebMvcConfigurerAdapter {
bean.setOrder(Ordered.LOWEST_PRECEDENCE); bean.setOrder(Ordered.LOWEST_PRECEDENCE);
bean.addInitParameter("com.sun.jersey.config.property.packages", bean.addInitParameter("com.sun.jersey.config.property.packages",
"com.netflix.discovery;com.netflix.eureka"); "com.netflix.discovery;com.netflix.eureka");
// bean.addInitParameter(ServletContainer.FEATURE_FILTER_FORWARD_ON_404, "true"); bean.addInitParameter("com.sun.jersey.config.feature.FilterContextPath", EurekaServerConfigBean.DEFAULT_PREFIX);
bean.setUrlPatterns(Lists.newArrayList("/v2/*")); bean.setUrlPatterns(Lists.newArrayList(EurekaServerConfigBean.DEFAULT_PATH + "/*"));
return bean; return bean;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment