Browse Source
This allows mappings to be at the root and not have to be prefixed. It also allows mappings to fall through to other handler mappings. Patterns are now Ant-style via AntPathMatcher. fixes gh-72pull/6/head
25 changed files with 402 additions and 439 deletions
@ -0,0 +1,117 @@
@@ -0,0 +1,117 @@
|
||||
package org.springframework.cloud.netflix.zuul; |
||||
|
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.bind.PropertySourceUtils; |
||||
import org.springframework.cloud.client.discovery.DiscoveryClient; |
||||
import org.springframework.cloud.context.environment.EnvironmentChangeEvent; |
||||
import org.springframework.context.ApplicationListener; |
||||
import org.springframework.core.env.*; |
||||
import org.springframework.util.ReflectionUtils; |
||||
|
||||
import java.lang.reflect.Field; |
||||
import java.util.*; |
||||
import java.util.concurrent.atomic.AtomicReference; |
||||
|
||||
/** |
||||
* @author Spencer Gibb |
||||
*/ |
||||
@Slf4j |
||||
public class RouteLocator implements ApplicationListener<EnvironmentChangeEvent> { |
||||
|
||||
public static final String DEFAULT_ROUTE = "/"; |
||||
|
||||
@Autowired |
||||
protected ConfigurableEnvironment env; |
||||
|
||||
@Autowired |
||||
protected DiscoveryClient discovery; |
||||
|
||||
@Autowired |
||||
protected ZuulProperties properties; |
||||
|
||||
private Field propertySourcesField; |
||||
private AtomicReference<LinkedHashMap<String, String>> routes = new AtomicReference<>(); |
||||
|
||||
public RouteLocator() { |
||||
initField(); |
||||
} |
||||
|
||||
private void initField() { |
||||
propertySourcesField = ReflectionUtils.findField(CompositePropertySource.class, "propertySources"); |
||||
propertySourcesField.setAccessible(true); |
||||
} |
||||
|
||||
@Override |
||||
public void onApplicationEvent(EnvironmentChangeEvent event) { |
||||
for (String key : event.getKeys()) { |
||||
if (key.startsWith(properties.getRoutePrefix())) { |
||||
routes.set(locateRoutes()); |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
|
||||
//TODO: respond to changes in eureka
|
||||
public Map<String, String> getRoutes() { |
||||
if (routes.get() == null) { |
||||
routes.set(locateRoutes()); |
||||
} |
||||
|
||||
return routes.get(); |
||||
} |
||||
|
||||
protected LinkedHashMap<String, String> locateRoutes() { |
||||
LinkedHashMap<String, String> routesMap = new LinkedHashMap<>(); |
||||
|
||||
//Add routes for discovery services by default
|
||||
List<String> services = discovery.getServices(); |
||||
for (String serviceId : services) { |
||||
//Ignore specified services
|
||||
if (!properties.getIgnoredServices().contains(serviceId)) |
||||
routesMap.put("/" + serviceId + "/**", serviceId); |
||||
} |
||||
|
||||
MutablePropertySources propertySources = env.getPropertySources(); |
||||
for (PropertySource<?> propertySource : propertySources) { |
||||
getRoutes(propertySource, routesMap); |
||||
} |
||||
|
||||
String defaultServiceId = routesMap.get(DEFAULT_ROUTE); |
||||
|
||||
if (defaultServiceId != null) { |
||||
//move the defaultServiceId to the end
|
||||
routesMap.remove(DEFAULT_ROUTE); |
||||
routesMap.put(DEFAULT_ROUTE, defaultServiceId); |
||||
} |
||||
return routesMap; |
||||
} |
||||
|
||||
protected void getRoutes(PropertySource<?> propertySource, Map<String, String> routes) { |
||||
if (propertySource instanceof CompositePropertySource) { |
||||
try { |
||||
@SuppressWarnings("unchecked") |
||||
Set<PropertySource<?>> sources = (Set<PropertySource<?>>) propertySourcesField.get(propertySource); |
||||
for (PropertySource<?> source : sources) { |
||||
getRoutes(source, routes); |
||||
} |
||||
} catch (IllegalAccessException e) { |
||||
return; |
||||
} |
||||
} else { |
||||
//EnumerablePropertySource enumerable = (EnumerablePropertySource) propertySource;
|
||||
MutablePropertySources propertySources = new MutablePropertySources(); |
||||
propertySources.addLast(propertySource); |
||||
Map<String, Object> routeEntries = PropertySourceUtils.getSubProperties(propertySources, properties.getRoutePrefix()); |
||||
for (Map.Entry<String, Object> entry : routeEntries.entrySet()) { |
||||
String serviceId = entry.getKey(); |
||||
String route = entry.getValue().toString(); |
||||
|
||||
if (routes.containsKey(route)) { |
||||
log.warn("Overwriting route {}: already defined by {}", route, routes.get(route)); |
||||
} |
||||
routes.put(route, serviceId); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,84 +0,0 @@
@@ -1,84 +0,0 @@
|
||||
package org.springframework.cloud.netflix.zuul; |
||||
|
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.bind.PropertySourceUtils; |
||||
import org.springframework.core.env.*; |
||||
import org.springframework.util.ReflectionUtils; |
||||
|
||||
import java.lang.reflect.Field; |
||||
import java.util.LinkedHashMap; |
||||
import java.util.Map; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* @author Spencer Gibb |
||||
*/ |
||||
public class Routes { |
||||
private static final Logger logger = LoggerFactory.getLogger(Routes.class); |
||||
|
||||
public static final String DEFAULT_ROUTE = "/"; |
||||
|
||||
@Autowired |
||||
ConfigurableEnvironment env; |
||||
private Field propertySourcesField; |
||||
private String keyPrefix; |
||||
|
||||
public Routes(String keyPrefix) { |
||||
this.keyPrefix = keyPrefix; |
||||
initField(); |
||||
} |
||||
|
||||
private void initField() { |
||||
propertySourcesField = ReflectionUtils.findField(CompositePropertySource.class, "propertySources"); |
||||
propertySourcesField.setAccessible(true); |
||||
} |
||||
|
||||
//TODO: cache routes or respond to environment event and refresh all routes
|
||||
public LinkedHashMap<String, String> getRoutes() { |
||||
LinkedHashMap<String, String> routes = new LinkedHashMap<>(); |
||||
MutablePropertySources propertySources = env.getPropertySources(); |
||||
for (PropertySource<?> propertySource : propertySources) { |
||||
getRoutes(propertySource, routes); |
||||
} |
||||
|
||||
String defaultServiceId = routes.get(DEFAULT_ROUTE); |
||||
|
||||
if (defaultServiceId != null) { |
||||
//move the defaultServiceId to the end
|
||||
routes.remove(DEFAULT_ROUTE); |
||||
routes.put(DEFAULT_ROUTE, defaultServiceId); |
||||
} |
||||
|
||||
return routes; |
||||
} |
||||
|
||||
public void getRoutes(PropertySource<?> propertySource, LinkedHashMap<String, String> routes) { |
||||
if (propertySource instanceof CompositePropertySource) { |
||||
try { |
||||
@SuppressWarnings("unchecked") |
||||
Set<PropertySource<?>> sources = (Set<PropertySource<?>>) propertySourcesField.get(propertySource); |
||||
for (PropertySource<?> source : sources) { |
||||
getRoutes(source, routes); |
||||
} |
||||
} catch (IllegalAccessException e) { |
||||
return; |
||||
} |
||||
} else { |
||||
//EnumerablePropertySource enumerable = (EnumerablePropertySource) propertySource;
|
||||
MutablePropertySources propertySources = new MutablePropertySources(); |
||||
propertySources.addLast(propertySource); |
||||
Map<String, Object> routeEntries = PropertySourceUtils.getSubProperties(propertySources, keyPrefix); |
||||
for (Map.Entry<String, Object> entry : routeEntries.entrySet()) { |
||||
String serviceId = entry.getKey(); |
||||
String route = entry.getValue().toString(); |
||||
|
||||
if (routes.containsKey(route)) { |
||||
logger.warn("Overwriting route {}: already defined by {}", route, routes.get(route)); |
||||
} |
||||
routes.put(route, serviceId); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
package org.springframework.cloud.netflix.zuul; |
||||
|
||||
import com.netflix.zuul.context.RequestContext; |
||||
import com.netflix.zuul.http.ZuulServlet; |
||||
import org.springframework.web.servlet.ModelAndView; |
||||
import org.springframework.web.servlet.mvc.ServletWrappingController; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
/** |
||||
* @author Spencer Gibb |
||||
*/ |
||||
public class ZuulController extends ServletWrappingController { |
||||
|
||||
public ZuulController() { |
||||
setServletClass(ZuulServlet.class); |
||||
setServletName("zuul"); |
||||
} |
||||
|
||||
@Override |
||||
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { |
||||
try { |
||||
return super.handleRequestInternal(request, response); |
||||
} finally { |
||||
// @see com.netflix.zuul.context.ContextLifecycleFilter.doFilter
|
||||
RequestContext.getCurrentContext().unset(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,65 @@
@@ -0,0 +1,65 @@
|
||||
package org.springframework.cloud.netflix.zuul; |
||||
|
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.context.ApplicationListener; |
||||
import org.springframework.context.event.ContextRefreshedEvent; |
||||
import org.springframework.util.StringUtils; |
||||
import org.springframework.web.servlet.handler.AbstractUrlHandlerMapping; |
||||
|
||||
import javax.annotation.PostConstruct; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author Spencer Gibb |
||||
*/ |
||||
@Slf4j |
||||
public class ZuulHandlerMapping extends AbstractUrlHandlerMapping implements ApplicationListener<ContextRefreshedEvent> { |
||||
|
||||
@Autowired |
||||
protected RouteLocator routeLocator; |
||||
|
||||
@Autowired |
||||
protected ZuulController zuul; |
||||
|
||||
@Autowired |
||||
protected ZuulProperties properties; |
||||
|
||||
public ZuulHandlerMapping() { |
||||
setOrder(-200); |
||||
} |
||||
|
||||
@PostConstruct |
||||
public void init() { |
||||
} |
||||
|
||||
@Override |
||||
public void onApplicationEvent(ContextRefreshedEvent event) { |
||||
registerHandlers(routeLocator.getRoutes()); |
||||
} |
||||
|
||||
private void registerHandlers(Map<String, String> routes) { |
||||
if (routes.isEmpty()) { |
||||
logger.warn("Neither 'urlMap' nor 'mappings' set on SimpleUrlHandlerMapping"); |
||||
} |
||||
else { |
||||
for (Map.Entry<String, String> entry : routes.entrySet()) { |
||||
String url = entry.getKey(); |
||||
// Prepend with slash if not already present.
|
||||
if (!url.startsWith("/")) { |
||||
url = "/" + url; |
||||
} |
||||
|
||||
if (StringUtils.hasText(properties.getRoutePrefix())) { |
||||
url = properties.getMapping()+url; |
||||
if (!url.startsWith("/")) { |
||||
url = "/" + url; |
||||
} |
||||
} |
||||
|
||||
registerHandler(url, zuul); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
@ -1,11 +1,20 @@
@@ -1,11 +1,20 @@
|
||||
package org.springframework.cloud.netflix.zuul; |
||||
|
||||
import lombok.Data; |
||||
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author Spencer Gibb |
||||
*/ |
||||
public interface ZuulProperties { |
||||
public String getMapping(); |
||||
public boolean isStripMapping(); |
||||
public String getRoutePrefix(); |
||||
public boolean isAddProxyHeaders(); |
||||
@Data |
||||
@ConfigurationProperties("zuul") |
||||
public class ZuulProperties { |
||||
private String mapping = ""; |
||||
private boolean stripMapping = false; |
||||
private String routePrefix = "zuul.route."; |
||||
private boolean addProxyHeaders = true; |
||||
private List<String> ignoredServices = Collections.emptyList(); |
||||
} |
||||
|
@ -1,55 +0,0 @@
@@ -1,55 +0,0 @@
|
||||
package org.springframework.cloud.netflix.zuul; |
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; |
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
import com.netflix.zuul.http.ZuulServlet; |
||||
|
||||
/** |
||||
* @author Spencer Gibb |
||||
*/ |
||||
@Configuration |
||||
@EnableConfigurationProperties(ZuulProxyProperties.class) |
||||
@ConditionalOnClass(ZuulServlet.class) |
||||
@ConditionalOnExpression("${zuul.proxy.enabled:true}") |
||||
public class ZuulProxyConfiguration extends AbstractZuulConfiguration { |
||||
|
||||
@Bean |
||||
public ZuulProxyProperties zuulProxyProperties() { |
||||
return new ZuulProxyProperties(); |
||||
} |
||||
|
||||
@Bean |
||||
//ZuulProxyProperties doesn't implement ZuulProperties so there are not 2 implementations (see ZuulServerConfiguration
|
||||
public ZuulProperties zuulProperties() { |
||||
return new ZuulProperties() { |
||||
@Override |
||||
public String getMapping() { |
||||
return zuulProxyProperties().getMapping(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean isStripMapping() { |
||||
return zuulProxyProperties().isStripMapping(); |
||||
} |
||||
|
||||
@Override |
||||
public String getRoutePrefix() { |
||||
return zuulProxyProperties().getRoutePrefix(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean isAddProxyHeaders() { |
||||
return zuulProxyProperties().isAddProxyHeaders(); |
||||
} |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
protected ZuulProperties getProperties() { |
||||
return zuulProperties(); |
||||
} |
||||
} |
@ -1,16 +0,0 @@
@@ -1,16 +0,0 @@
|
||||
package org.springframework.cloud.netflix.zuul; |
||||
|
||||
import lombok.Data; |
||||
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
||||
/** |
||||
* @author Spencer Gibb |
||||
*/ |
||||
@Data |
||||
@ConfigurationProperties("zuul.proxy") |
||||
public class ZuulProxyProperties { |
||||
private String mapping = "/proxy"; |
||||
private boolean stripMapping = true; // this is currently the default behaviour
|
||||
private String routePrefix = "zuul.proxy.route."; |
||||
private boolean addProxyHeaders = false; // TODO: current CF demo's rely on this
|
||||
} |
@ -0,0 +1,71 @@
@@ -0,0 +1,71 @@
|
||||
package org.springframework.cloud.netflix.zuul; |
||||
|
||||
import com.google.common.collect.Lists; |
||||
import org.junit.Before; |
||||
import org.junit.Test; |
||||
import org.mockito.Mock; |
||||
import org.springframework.cloud.client.discovery.DiscoveryClient; |
||||
import org.springframework.core.env.ConfigurableEnvironment; |
||||
import org.springframework.core.env.MutablePropertySources; |
||||
import org.springframework.mock.env.MockPropertySource; |
||||
|
||||
import java.util.Map; |
||||
|
||||
import static org.junit.Assert.*; |
||||
import static org.mockito.Mockito.*; |
||||
import static org.mockito.MockitoAnnotations.initMocks; |
||||
|
||||
/** |
||||
* @author Spencer Gibb |
||||
*/ |
||||
public class RouteLocatorTests { |
||||
|
||||
public static final String IGNOREDSERVICE = "ignoredservice"; |
||||
public static final String ASERVICE = "aservice"; |
||||
public static final String MYSERVICE = "myservice"; |
||||
@Mock |
||||
ConfigurableEnvironment env; |
||||
|
||||
@Mock |
||||
DiscoveryClient discovery; |
||||
|
||||
|
||||
@Before |
||||
public void init() { |
||||
initMocks(this); |
||||
} |
||||
|
||||
@Test |
||||
public void testGetRoutes() { |
||||
RouteLocator routeLocator = new RouteLocator(); |
||||
routeLocator.properties = new ZuulProperties(); |
||||
routeLocator.properties.setIgnoredServices(Lists.newArrayList(IGNOREDSERVICE)); |
||||
routeLocator.discovery = this.discovery; |
||||
routeLocator.env = this.env; |
||||
|
||||
MutablePropertySources propertySources = new MutablePropertySources(); |
||||
propertySources.addFirst(new MockPropertySource().withProperty("zuul.route."+ ASERVICE, getMapping(ASERVICE))); |
||||
when(env.getPropertySources()).thenReturn(propertySources); |
||||
when(discovery.getServices()).thenReturn(Lists.newArrayList(MYSERVICE, IGNOREDSERVICE)); |
||||
|
||||
Map<String, String> routesMap = routeLocator.getRoutes(); |
||||
|
||||
assertNotNull("routesMap was null", routesMap); |
||||
assertFalse("routesMap was empty", routesMap.isEmpty()); |
||||
assertMapping(routesMap, MYSERVICE); |
||||
assertMapping(routesMap, ASERVICE); |
||||
|
||||
String serviceId = routesMap.get(getMapping(IGNOREDSERVICE)); |
||||
assertNull("routes did not ignore "+IGNOREDSERVICE, serviceId); |
||||
} |
||||
|
||||
protected void assertMapping(Map<String, String> routesMap, String expectedServiceId) { |
||||
String mapping = getMapping(expectedServiceId); |
||||
String serviceId = routesMap.get(mapping); |
||||
assertEquals("routesMap had wrong value for "+mapping, expectedServiceId, serviceId); |
||||
} |
||||
|
||||
private String getMapping(String serviceId) { |
||||
return "/"+ serviceId +"/**"; |
||||
} |
||||
} |
@ -1,77 +0,0 @@
@@ -1,77 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<artifactId>spring-cloud-netflix-zuul-server</artifactId> |
||||
<packaging>jar</packaging> |
||||
<name>Spring Cloud Netflix Zuul Server</name> |
||||
<url>http://projects.spring.io/spring-cloud/</url> |
||||
<parent> |
||||
<groupId>org.springframework.cloud</groupId> |
||||
<artifactId>spring-cloud-netflix</artifactId> |
||||
<version>1.0.0.BUILD-SNAPSHOT</version> |
||||
<relativePath>..</relativePath> |
||||
</parent> |
||||
|
||||
<build> |
||||
<plugins> |
||||
</plugins> |
||||
</build> |
||||
|
||||
<properties> |
||||
</properties> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.springframework.cloud</groupId> |
||||
<artifactId>spring-cloud-netflix-core</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.netflix.eureka</groupId> |
||||
<artifactId>eureka-client</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.netflix.hystrix</groupId> |
||||
<artifactId>hystrix-core</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.netflix.hystrix</groupId> |
||||
<artifactId>hystrix-metrics-event-stream</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.netflix.hystrix</groupId> |
||||
<artifactId>hystrix-javanica</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.netflix.ribbon</groupId> |
||||
<artifactId>ribbon</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.netflix.ribbon</groupId> |
||||
<artifactId>ribbon-core</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.netflix.ribbon</groupId> |
||||
<artifactId>ribbon-eureka</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.netflix.ribbon</groupId> |
||||
<artifactId>ribbon-httpclient</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.netflix.zuul</groupId> |
||||
<artifactId>zuul-core</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.projectlombok</groupId> |
||||
<artifactId>lombok</artifactId> |
||||
<!-- Only needed at compile time --> |
||||
<scope>provided</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-test</artifactId> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
</dependencies> |
||||
</project> |
@ -1,54 +0,0 @@
@@ -1,54 +0,0 @@
|
||||
package org.springframework.cloud.netflix.zuul; |
||||
|
||||
import com.netflix.zuul.http.ZuulServlet; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; |
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
/** |
||||
* @author Spencer Gibb |
||||
*/ |
||||
@Configuration |
||||
@ConditionalOnClass(ZuulServlet.class) |
||||
@EnableConfigurationProperties(ZuulServerProperties.class) |
||||
@ConditionalOnExpression("${zuul.server.enabled:true}") |
||||
public class ZuulServerConfiguration extends AbstractZuulConfiguration { |
||||
|
||||
@Bean |
||||
public ZuulServerProperties zuulServerProperties() { |
||||
return new ZuulServerProperties(); |
||||
} |
||||
|
||||
@Bean |
||||
//ZuulServerProperties doesn't implement ZuulProperties so there are not 2 implementations (see ZuulProxyConfiguration
|
||||
public ZuulProperties zuulProperties() { |
||||
return new ZuulProperties() { |
||||
@Override |
||||
public String getMapping() { |
||||
return zuulServerProperties().getMapping(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean isStripMapping() { |
||||
return zuulServerProperties().isStripMapping(); |
||||
} |
||||
|
||||
@Override |
||||
public String getRoutePrefix() { |
||||
return zuulServerProperties().getRoutePrefix(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean isAddProxyHeaders() { |
||||
return zuulServerProperties().isAddProxyHeaders(); |
||||
} |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
protected ZuulProperties getProperties() { |
||||
return zuulProperties(); |
||||
} |
||||
} |
@ -1,16 +0,0 @@
@@ -1,16 +0,0 @@
|
||||
package org.springframework.cloud.netflix.zuul; |
||||
|
||||
import lombok.Data; |
||||
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
||||
/** |
||||
* @author Spencer Gibb |
||||
*/ |
||||
@Data |
||||
@ConfigurationProperties("zuul.server") |
||||
public class ZuulServerProperties { |
||||
private String mapping = ""; |
||||
private boolean stripMapping = false; |
||||
private String routePrefix = "zuul.server.route."; |
||||
private boolean addProxyHeaders = true; |
||||
} |
@ -1,16 +0,0 @@
@@ -1,16 +0,0 @@
|
||||
package org.springframework.cloud.netflix.zuul; |
||||
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
||||
import org.springframework.boot.builder.SpringApplicationBuilder; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
@Configuration |
||||
@EnableAutoConfiguration |
||||
@EnableZuulServer |
||||
public class ZuulServerApplication { |
||||
|
||||
public static void main(String[] args) { |
||||
new SpringApplicationBuilder(ZuulServerApplication.class).web(true).run(args); |
||||
} |
||||
|
||||
} |
@ -1,20 +0,0 @@
@@ -1,20 +0,0 @@
|
||||
package org.springframework.cloud.netflix.zuul; |
||||
|
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.springframework.boot.test.IntegrationTest; |
||||
import org.springframework.boot.test.SpringApplicationConfiguration; |
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
||||
import org.springframework.test.context.web.WebAppConfiguration; |
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class) |
||||
@SpringApplicationConfiguration(classes = ZuulServerApplication.class) |
||||
@WebAppConfiguration |
||||
@IntegrationTest("server.port=0") |
||||
public class ZuulServerApplicationTests { |
||||
|
||||
@Test |
||||
public void contextLoads() { |
||||
} |
||||
|
||||
} |
@ -1,18 +0,0 @@
@@ -1,18 +0,0 @@
|
||||
server: |
||||
port: 9876 |
||||
servletPath: /app |
||||
management: |
||||
port: 9877 |
||||
spring: |
||||
application: |
||||
name: testzuulserver |
||||
error: |
||||
path: ${server.servletPath}/error |
||||
|
||||
zuul: |
||||
server: |
||||
route: |
||||
testclient: /testing123 |
||||
stores: /stores |
||||
customers: /customers |
||||
|
Loading…
Reference in new issue