Commit 8fbba2b0 by Spencer Gibb

@EnableZuulProxy initial implementation

parent a2e8245e
......@@ -81,6 +81,16 @@
<artifactId>ribbon-eureka</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.netflix.ribbon</groupId>
<artifactId>ribbon-httpclient</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.netflix.zuul</groupId>
<artifactId>zuul-core</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
......
......@@ -66,7 +66,7 @@ public class EurekaInstanceConfigBean implements EurekaInstanceConfig {
private int leaseExpirationDurationInSeconds = 90;
@Value("${spring.application.name:unknown}.mydomain.net")
@Value("${spring.application.name:unknown}") //TODO: why is .mydomain.net here?
private String virtualHostName;
private String secureVirtualHostName;
......
......@@ -50,11 +50,11 @@ public class FeignConfigurer {
protected <T> T loadBalance(Feign.Builder builder, Class<T> type, String schemeName) {
String name = URI.create(schemeName).getHost();
setServiceListClass(name);
setServiceListClassAndVIP(name);
return builder.target(LoadBalancingTarget.create(type, schemeName));
}
public static void setServiceListClass(String serviceId) {
public static void setServiceListClassAndVIP(String serviceId) {
setProp(serviceId, "NIWSServerListClassName", DiscoveryEnabledNIWSServerList.class.getName());
setProp(serviceId, "DeploymentContextBasedVipAddresses", serviceId); //FIXME: what should this be?
}
......
package org.springframework.platform.netflix.zuul;
import java.lang.annotation.*;
import org.springframework.context.annotation.Import;
/**
* @author Spencer Gibb
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import(ZuulProxyConfiguration.class)
public @interface EnableZuulProxy {
}
package org.springframework.platform.netflix.zuul;
import com.netflix.zuul.FilterFileManager;
import com.netflix.zuul.FilterLoader;
import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.filters.FilterRegistry;
import com.netflix.zuul.groovy.GroovyCompiler;
import com.netflix.zuul.groovy.GroovyFileFilter;
import com.netflix.zuul.monitoring.MonitoringHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.List;
import java.util.Map;
/**
* User: spencergibb
* Date: 4/24/14
* Time: 9:23 PM
* TODO: .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
*/
public class FilterIntializer implements ServletContextListener {
private static final Logger LOGGER = LoggerFactory.getLogger(FilterIntializer.class);
@Autowired
private Map<String, ZuulFilter> filters;
@Override
public void contextInitialized(ServletContextEvent sce) {
LOGGER.info("Starting filter initialzer context listener");
//FIXME: mocks monitoring infrastructure as we don't need it for this simple app
MonitoringHelper.initMocks();
FilterRegistry registry = FilterRegistry.instance();
for (Map.Entry<String, ZuulFilter> entry : filters.entrySet()) {
registry.put(entry.getKey(), entry.getValue());
}
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
LOGGER.info("Stopping filter initializer context listener");
}
/*private void initGroovyFilterManager() {
//TODO: support groovy filters loaded from filesystem in proxy
FilterLoader.getInstance().setCompiler(new GroovyCompiler());
final String scriptRoot = props.getFilterRoot();
LOGGER.info("Using file system script: " + scriptRoot);
try {
FilterFileManager.setFilenameFilter(new GroovyFileFilter());
FilterFileManager.init(5,
scriptRoot + "/pre",
scriptRoot + "/route",
scriptRoot + "/post"
);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}*/
}
package io.spring.platform.netflix.zuul;
package org.springframework.platform.netflix.zuul;
import com.netflix.client.http.HttpRequest;
import com.netflix.client.http.HttpResponse;
......
package io.spring.platform.netflix.zuul;
package org.springframework.platform.netflix.zuul;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -22,9 +22,20 @@ public class Routes {
@Autowired
ConfigurableEnvironment env;
private final Field propertySourcesField;
private Field propertySourcesField;
private String keyPrefix;
public Routes() {
keyPrefix = "zuul.route.";
initField();
}
public Routes(String keyPrefix) {
this.keyPrefix = keyPrefix;
initField();
}
private void initField() {
propertySourcesField = ReflectionUtils.findField(CompositePropertySource.class, "propertySources");
propertySourcesField.setAccessible(true);
}
......@@ -63,7 +74,7 @@ public class Routes {
//EnumerablePropertySource enumerable = (EnumerablePropertySource) propertySource;
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addLast(propertySource);
Map<String, Object> routeEntries = PropertySourceUtils.getSubProperties(propertySources, "zuul.route.");
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();
......
package io.spring.platform.netflix.zuul;
package org.springframework.platform.netflix.zuul;
import com.netflix.zuul.ZuulFilter;
import org.springframework.web.context.WebApplicationContext;
......
package org.springframework.platform.netflix.zuul;
import com.netflix.zuul.context.ContextLifecycleFilter;
import com.netflix.zuul.http.ZuulServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.context.embedded.FilterRegistrationBean;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.platform.netflix.zuul.filters.post.SendResponseFilter;
import org.springframework.platform.netflix.zuul.filters.post.StatsFilter;
import org.springframework.platform.netflix.zuul.filters.pre.DebugFilter;
import org.springframework.platform.netflix.zuul.filters.pre.DebugRequestFilter;
import org.springframework.platform.netflix.zuul.filters.pre.PreDecorationFilter;
import org.springframework.platform.netflix.zuul.filters.route.RibbonRoutingFilter;
import java.util.ArrayList;
import java.util.Collection;
/**
* @author Spencer Gibb
*/
@Configuration
@EnableConfigurationProperties(ZuulProxyProperties.class)
@ConditionalOnClass(ZuulServlet.class)
@ConditionalOnExpression("${zuul.proxy.enabled:true}")
public class ZuulProxyConfiguration {
@Autowired
private ZuulProxyProperties props;
@Bean
public FilterRegistrationBean contextLifecycleFilter() {
Collection<String> urlPatterns = new ArrayList<>();
urlPatterns.add(props.getMapping()+"/*");
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new ContextLifecycleFilter());
filterRegistrationBean.setUrlPatterns(urlPatterns);
return filterRegistrationBean;
}
@Bean
public ServletRegistrationBean zuulServlet() {
return new ServletRegistrationBean(new ZuulServlet(), props.getMapping()+"/*");
}
@Bean
Routes routes() {
return new Routes("zuul.proxy.route.");
}
@Bean
FilterIntializer filterIntializer() {
return new FilterIntializer();
}
// pre filters
@Bean
public DebugFilter debugFilter() {
return new DebugFilter();
}
@Bean
public DebugRequestFilter debugRequestFilter() {
return new DebugRequestFilter();
}
@Bean
public PreDecorationFilter preDecorationFilter() {
return new PreDecorationFilter();
}
// route filters
@Bean
public RibbonRoutingFilter ribbonRoutingFilter() {
return new RibbonRoutingFilter();
}
// post filters
@Bean
public SendResponseFilter sendResponseFilter() {
return new SendResponseFilter();
}
@Bean
public StatsFilter statsFilter() {
return new StatsFilter();
}
}
package org.springframework.platform.netflix.zuul;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* Created by sgibb on 8/5/14.
*/
@Data
@ConfigurationProperties("zuul.proxy")
public class ZuulProxyProperties {
private String mapping = "/proxy";
}
package org.springframework.platform.netflix.zuul.filters.post;
import com.google.common.base.Throwables;
import com.netflix.config.DynamicBooleanProperty;
import com.netflix.config.DynamicIntProperty;
import com.netflix.config.DynamicPropertyFactory;
import com.netflix.util.Pair;
import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.constants.ZuulConstants;
import com.netflix.zuul.constants.ZuulHeaders;
import com.netflix.zuul.context.Debug;
import com.netflix.zuul.context.RequestContext;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.zip.GZIPInputStream;
public class SendResponseFilter extends ZuulFilter {
static DynamicBooleanProperty INCLUDE_DEBUG_HEADER =
DynamicPropertyFactory.getInstance().getBooleanProperty(ZuulConstants.ZUUL_INCLUDE_DEBUG_HEADER, false);
static DynamicIntProperty INITIAL_STREAM_BUFFER_SIZE =
DynamicPropertyFactory.getInstance().getIntProperty(ZuulConstants.ZUUL_INITIAL_STREAM_BUFFER_SIZE, 1024);
static DynamicBooleanProperty SET_CONTENT_LENGTH = DynamicPropertyFactory.getInstance().getBooleanProperty(ZuulConstants.ZUUL_SET_CONTENT_LENGTH, false);
@Override
public String filterType() {
return "post";
}
@Override
public int filterOrder() {
return 1000;
}
public boolean shouldFilter() {
return !RequestContext.getCurrentContext().getZuulResponseHeaders().isEmpty() ||
RequestContext.getCurrentContext().getResponseDataStream() != null ||
RequestContext.getCurrentContext().getResponseBody() != null;
}
public Object run() {
try {
addResponseHeaders();
writeResponse();
} catch (Exception e) {
Throwables.propagate(e);
}
return null;
}
void writeResponse() throws Exception {
RequestContext context = RequestContext.getCurrentContext();
// there is no body to send
if (context.getResponseBody() == null && context.getResponseDataStream() == null) return;
HttpServletResponse servletResponse = context.getResponse();
servletResponse.setCharacterEncoding("UTF-8");
OutputStream outStream = servletResponse.getOutputStream();
InputStream is = null;
try {
if (RequestContext.getCurrentContext().getResponseBody() != null) {
String body = RequestContext.getCurrentContext().getResponseBody();
writeResponse(new ByteArrayInputStream(body.getBytes()), outStream);
return;
}
boolean isGzipRequested = false;
final String requestEncoding = context.getRequest().getHeader(ZuulHeaders.ACCEPT_ENCODING);
if (requestEncoding != null && requestEncoding.equals("gzip"))
isGzipRequested = true;
is = context.getResponseDataStream();
InputStream inputStream = is;
if (is != null) {
if (context.sendZuulResponse()) {
// if origin response is gzipped, and client has not requested gzip, decompress stream
// before sending to client
// else, stream gzip directly to client
if (context.getResponseGZipped() && !isGzipRequested)
try {
inputStream = new GZIPInputStream(is);
} catch (java.util.zip.ZipException e) {
System.out.println("gzip expected but not received assuming unencoded response" +
RequestContext.getCurrentContext().getRequest().getRequestURL().toString());
inputStream = is;
}
else if (context.getResponseGZipped() && isGzipRequested)
servletResponse.setHeader(ZuulHeaders.CONTENT_ENCODING, "gzip");
writeResponse(inputStream, outStream);
}
}
} finally {
try {
if (is != null)
is.close();
outStream.flush();
outStream.close();
} catch (IOException e) {
}
}
}
private void writeResponse(InputStream zin, OutputStream out) throws Exception {
byte[] bytes = new byte[INITIAL_STREAM_BUFFER_SIZE.get()];
int bytesRead = -1;
while ((bytesRead = zin.read(bytes)) != -1) {
// if (Debug.debugRequest() && !Debug.debugRequestHeadersOnly()) {
// Debug.addRequestDebug("OUTBOUND: < " + new String(bytes, 0, bytesRead));
// }
try {
out.write(bytes, 0, bytesRead);
out.flush();
} catch (IOException e) {
//ignore
e.printStackTrace();
}
// doubles buffer size if previous read filled it
if (bytesRead == bytes.length) {
bytes = new byte[bytes.length * 2];
}
}
}
private void addResponseHeaders() {
RequestContext context = RequestContext.getCurrentContext();
HttpServletResponse servletResponse = context.getResponse();
List<Pair<String, String>> zuulResponseHeaders = context.getZuulResponseHeaders();
String debugHeader = "";
List<String> rd = (List<String>) RequestContext.getCurrentContext().get("routingDebug");
for (String it : rd) {
debugHeader += "[[["+it+"]]]";
}
/*
rd = (List<String>) RequestContext.getCurrentContext().get("requestDebug");
rd?.each {
debugHeader += "[[[REQUEST_DEBUG::${it}]]]";
}
*/
if (INCLUDE_DEBUG_HEADER.get()) servletResponse.addHeader("X-Zuul-Debug-Header", debugHeader);
if (Debug.debugRequest() && zuulResponseHeaders != null) {
for (Pair<String, String> it : zuulResponseHeaders) {
servletResponse.addHeader(it.first(), it.second());
Debug.addRequestDebug("OUTBOUND: < " + it.first() + ":" + it.second());
}
} else if (zuulResponseHeaders != null) {
for (Pair<String, String> it : zuulResponseHeaders) {
servletResponse.addHeader(it.first(), it.second());
}
}
RequestContext ctx = RequestContext.getCurrentContext();
Integer contentLength = ctx.getOriginContentLength();
// only inserts Content-Length if origin provides it and origin response is not gzipped
if (SET_CONTENT_LENGTH.get()) {
if (contentLength != null && !ctx.getResponseGZipped())
servletResponse.setContentLength(contentLength);
}
}
}
\ No newline at end of file
package org.springframework.platform.netflix.zuul.filters.post;
import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import java.util.List;
public class StatsFilter extends ZuulFilter {
@Override
public String filterType() {
return "post";
}
@Override
public int filterOrder() {
return 2000;
}
@Override
public boolean shouldFilter() {
return true;
}
@Override
public Object run() {
dumpRoutingDebug();
dumpRequestDebug();
return null;
}
public void dumpRequestDebug() {
List<String> rd = (List<String>) RequestContext.getCurrentContext().get("requestDebug");
if (rd != null) {
for (String it : rd) {
System.out.println("REQUEST_DEBUG::" + it);
}
}
}
public void dumpRoutingDebug() {
List<String> rd = (List<String>) RequestContext.getCurrentContext().get("routingDebug");
if (rd != null) {
for (String it : rd) {
System.out.println("ZUUL_DEBUG::"+it);
}
}
}
}
package org.springframework.platform.netflix.zuul.filters.pre;
import com.netflix.config.DynamicBooleanProperty;
import com.netflix.config.DynamicPropertyFactory;
import com.netflix.config.DynamicStringProperty;
import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.constants.ZuulConstants;
import com.netflix.zuul.context.RequestContext;
import javax.servlet.http.HttpServletRequest;
public class DebugFilter extends ZuulFilter {
static final DynamicBooleanProperty routingDebug = DynamicPropertyFactory.getInstance()
.getBooleanProperty(ZuulConstants.ZUUL_DEBUG_REQUEST, true);
static final DynamicStringProperty debugParameter = DynamicPropertyFactory.getInstance()
.getStringProperty(ZuulConstants.ZUUL_DEBUG_PARAMETER, "d");
@Override
public String filterType() {
return "pre";
}
@Override
public int filterOrder() {
return 1;
}
public boolean shouldFilter() {
HttpServletRequest request = RequestContext.getCurrentContext().getRequest();
if ("true".equals(request.getParameter(debugParameter.get())))
return true;
return routingDebug.get();
}
public Object run() {
RequestContext ctx = RequestContext.getCurrentContext();
ctx.setDebugRouting(true);
ctx.setDebugRequest(true);
return null;
}
}
package org.springframework.platform.netflix.zuul.filters.pre;
import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.Debug;
import com.netflix.zuul.context.RequestContext;
import org.apache.commons.io.IOUtils;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
public class DebugRequestFilter extends ZuulFilter {
@Override
public String filterType() {
return "pre";
}
@Override
public int filterOrder() {
return 10000;
}
@Override
public boolean shouldFilter() {
return Debug.debugRequest();
}
@Override
public Object run() {
HttpServletRequest req = RequestContext.getCurrentContext().getRequest();
Debug.addRequestDebug("REQUEST:: " + req.getScheme() + " " + req.getRemoteAddr() + ":" + req.getRemotePort());
Debug.addRequestDebug("REQUEST:: > " + req.getMethod() + " " + req.getRequestURI() + " " + req.getProtocol());
Enumeration<String> headerIt = req.getHeaderNames();
while (headerIt.hasMoreElements()) {
String name = headerIt.nextElement();
String value = req.getHeader(name);
Debug.addRequestDebug("REQUEST:: > " + name + ":" + value);
}
final RequestContext ctx = RequestContext.getCurrentContext();
if (!ctx.isChunkedRequestBody()) {
try {
InputStream inp = ctx.getRequest().getInputStream();
if (inp != null) {
String body = IOUtils.toString(inp);
Debug.addRequestDebug("REQUEST:: > " + body);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return null;
}
}
package org.springframework.platform.netflix.zuul.filters.pre;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.platform.netflix.zuul.Routes;
import org.springframework.platform.netflix.zuul.ZuulProxyProperties;
import javax.annotation.Nullable;
import java.util.LinkedHashMap;
public class PreDecorationFilter extends ZuulFilter {
private static Logger LOG = LoggerFactory.getLogger(PreDecorationFilter.class);
@Autowired
private Routes routes;
@Autowired
private ZuulProxyProperties properties;
@Override
public int filterOrder() {
return 5;
}
@Override
public String filterType() {
return "pre";
}
@Override
public boolean shouldFilter() {
return true;
}
@Override
public Object run() {
RequestContext ctx = RequestContext.getCurrentContext();
String requestURI = ctx.getRequest().getRequestURI();
//remove proxy prefix TODO: only if embedded proxy
String proxyMapping = properties.getMapping();
final String uriPart = requestURI.replace(proxyMapping, ""); //TODO: better strategy?
ctx.put("requestURI", uriPart);
LinkedHashMap<String, String> routesMap = routes.getRoutes();
Optional<String> route = Iterables.tryFind(routesMap.keySet(), new Predicate<String>() {
@Override
public boolean apply(@Nullable String path) {
return uriPart.startsWith(path);
}
});
if (route.isPresent()) {
String serviceId = routesMap.get(route.get());
if (serviceId != null) {
// set serviceId for use in filters.route.RibbonRequest
ctx.set("serviceId", serviceId);
ctx.setRouteHost(null);
ctx.addOriginResponseHeader("X-Zuul-ServiceId", serviceId);
}
} else {
LOG.warn("No route found for uri: "+requestURI);
//TODO: 404
}
return null;
}
}
package org.springframework.platform.netflix.zuul.sample;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.platform.netflix.eureka.EnableEurekaClient;
import org.springframework.platform.netflix.zuul.EnableZuulProxy;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Configuration
@ComponentScan
@EnableAutoConfiguration
@RestController
@EnableZuulProxy
@EnableEurekaClient
public class Application {
@RequestMapping("/testing123")
public String testing123() {
return "testing123";
}
@RequestMapping("/")
public String home() {
return "Hello world";
}
public static void main(String[] args) {
new SpringApplicationBuilder(Application.class).web(true).run(args);
}
}
package org.springframework.platform.netflix.zuul.sample;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
public class ApplicationTests {
@Test
public void contextLoads() {
}
}
server:
port: 9000
port: 9999
spring:
application:
name: client
name: testclient
eureka:
server:
enabled: false
client:
serviceUrl:
defaultZone: http://localhost:8080/v2/
default.defaultZone: http://localhost:8080/v2/
zuul:
proxy:
route:
testclient: /testing123
stores: /stores
......@@ -8,6 +8,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.platform.netflix.endpoint.HystrixStreamEndpoint;
import org.springframework.platform.netflix.zuul.Routes;
import org.springframework.scheduling.annotation.EnableScheduling;
import java.util.ArrayList;
......
......@@ -11,7 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
//import javax.servlet.http.HttpSessionEvent;
/**
* User: spencergibb
......@@ -19,7 +18,7 @@ import javax.servlet.ServletContextListener;
* Time: 9:23 PM
* TODO: .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
*/
public class FilterIntializer implements ServletContextListener/*, HttpSessionListener*/ {
public class FilterIntializer implements ServletContextListener {
private static final Logger LOGGER = LoggerFactory.getLogger(FilterIntializer.class);
......@@ -27,9 +26,6 @@ public class FilterIntializer implements ServletContextListener/*, HttpSessionLi
ZuulProperties props;
@Override
/*public void sessionCreated(HttpSessionEvent se) {
contextInitialized(null);
}*/
public void contextInitialized(ServletContextEvent sce) {
LOGGER.info("Starting filter initialzer context listener");
......@@ -42,9 +38,6 @@ public class FilterIntializer implements ServletContextListener/*, HttpSessionLi
}
@Override
/*public void sessionDestroyed(HttpSessionEvent se) {
contextDestroyed(null);
}*/
public void contextDestroyed(ServletContextEvent sce) {
LOGGER.info("Stopping filter initializer context listener");
}
......
......@@ -3,8 +3,8 @@ package filters.pre
import com.netflix.zuul.context.RequestContext
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import io.spring.platform.netflix.zuul.Routes
import io.spring.platform.netflix.zuul.SpringFilter
import org.springframework.platform.netflix.zuul.Routes
import org.springframework.platform.netflix.zuul.SpringFilter
class PreDecorationFilter extends SpringFilter {
private static Logger LOG = LoggerFactory.getLogger(PreDecorationFilter.class);
......
......@@ -15,14 +15,14 @@ import com.netflix.zuul.util.HTTPRequestUtils
import com.sun.jersey.core.util.MultivaluedMapImpl
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import io.spring.platform.netflix.zuul.RibbonCommand
import org.springframework.platform.netflix.zuul.RibbonCommand
import javax.servlet.http.HttpServletRequest
import javax.ws.rs.core.MultivaluedMap
import java.util.zip.GZIPInputStream
import static HttpRequest.Verb
import static org.springframework.platform.netflix.feign.FeignConfigurer.setServiceListClass
import static org.springframework.platform.netflix.feign.FeignConfigurer.setServiceListClassAndVIP
class RibbonRequest extends ZuulFilter {
......@@ -57,7 +57,7 @@ class RibbonRequest extends ZuulFilter {
def serviceId = context.get("serviceId")
//TODO: can this be set be default? or an implementation of an interface?
setServiceListClass(serviceId)
setServiceListClassAndVIP(serviceId)
IClient restClient = ClientFactory.getNamedClient(serviceId);
......
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