This commit is contained in:
Spencer Gibb
2017-01-26 15:16:59 -07:00
parent 3084a2a633
commit 111cca2cb5

View File

@@ -1,30 +1,21 @@
package org.springframework.cloud.gateway.config;
import java.util.Collections;
import java.util.Map;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.core.Ordered;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MapPropertySource;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* @author Spencer Gibb
*/
public class GatewayEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered {
private static final Map<String, Object> PROPERTIES;
public static final int DEFAULT_ORDER = Ordered.HIGHEST_PRECEDENCE + 10;
static {
Map<String, Object> properties = new HashMap<>();
properties.put("spring.resources.add-mappings", "false");
PROPERTIES = Collections.unmodifiableMap(properties);
}
@Override
public int getOrder() {
return DEFAULT_ORDER;
@@ -34,7 +25,8 @@ public class GatewayEnvironmentPostProcessor implements EnvironmentPostProcessor
public void postProcessEnvironment(ConfigurableEnvironment configurableEnvironment, SpringApplication springApplication) {
//TODO: make this configurable?
//TODO: should I have to do this?
configurableEnvironment.getPropertySources().addLast(new MapPropertySource("gateway", PROPERTIES));
final Map<String, Object> properties = Collections.singletonMap("spring.resources.add-mappings", "false");
configurableEnvironment.getPropertySources().addLast(new MapPropertySource("gateway", properties));
}
}