Browse Source

Adds `@EnableGateway` annotation.

This creates a marker bean which then
pull/41/head
Spencer Gibb 8 years ago
parent
commit
9a3ac57ce6
No known key found for this signature in database
GPG Key ID: 7788A47380690861
  1. 44
      spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/EnableGateway.java
  2. 1
      spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java
  3. 34
      spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/config/GatewayConfiguration.java
  4. 2
      spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/route/AddRequestHeaderRouteFilterIntegrationTests.java
  5. 2
      spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/route/AddRequestParameterRouteFilterIntegrationTests.java
  6. 2
      spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/route/RedirectToRouteFilterIntegrationTests.java
  7. 2
      spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/route/RemoveNonProxyHeadersRouteFilterIntegrationTests.java
  8. 2
      spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/route/RemoveRequestHeaderRouteFilterIntegrationTests.java
  9. 4
      spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/route/RewritePathRouteFilterIntegrationTests.java
  10. 2
      spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/route/SecureHeadersRouteFilterIntegrationTests.java
  11. 2
      spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/route/SetPathRouteFilterIntegrationTests.java
  12. 2
      spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/route/SetResponseRouteFilterIntegrationTests.java
  13. 2
      spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/route/SetStatusRouteFilterIntegrationTests.java
  14. 2
      spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/test/BaseWebClientTests.java
  15. 2
      spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/test/FormIntegrationTests.java
  16. 2
      spring-cloud-gateway-sample/src/main/java/org/springframework/cloud/gateway/sample/GatewaySampleApplication.java

44
spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/EnableGateway.java

@ -0,0 +1,44 @@ @@ -0,0 +1,44 @@
/*
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.springframework.cloud.gateway;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.gateway.config.GatewayConfiguration;
import org.springframework.context.annotation.Import;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation to activate Spring Cloud Gateway configuration {@link org.springframework.cloud.gateway.config.GatewayAutoConfiguration}
*
* @author Spencer Gibb
*
*/
@EnableDiscoveryClient
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import(GatewayConfiguration.class)
public @interface EnableGateway {
}

1
spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java

@ -77,6 +77,7 @@ import rx.RxReactiveStreams; @@ -77,6 +77,7 @@ import rx.RxReactiveStreams;
* @author Spencer Gibb
*/
@Configuration
@ConditionalOnBean(GatewayConfiguration.Marker.class)
@EnableConfigurationProperties
public class GatewayAutoConfiguration {

34
spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/config/GatewayConfiguration.java

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
/*
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.springframework.cloud.gateway.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author Spencer Gibb
*/
@Configuration
public class GatewayConfiguration {
@Bean
public Marker gatewayMarker() {
return new Marker();
}
class Marker { }
}

2
spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/route/AddRequestHeaderRouteFilterIntegrationTests.java

@ -24,6 +24,7 @@ import org.junit.runner.RunWith; @@ -24,6 +24,7 @@ import org.junit.runner.RunWith;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.gateway.EnableGateway;
import org.springframework.cloud.gateway.test.BaseWebClientTests;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
@ -61,6 +62,7 @@ public class AddRequestHeaderRouteFilterIntegrationTests extends BaseWebClientTe @@ -61,6 +62,7 @@ public class AddRequestHeaderRouteFilterIntegrationTests extends BaseWebClientTe
@EnableAutoConfiguration
@SpringBootConfiguration
@EnableGateway
public static class TestConfig { }
}

2
spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/route/AddRequestParameterRouteFilterIntegrationTests.java

@ -24,6 +24,7 @@ import org.junit.runner.RunWith; @@ -24,6 +24,7 @@ import org.junit.runner.RunWith;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.gateway.EnableGateway;
import org.springframework.cloud.gateway.test.BaseWebClientTests;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
@ -70,6 +71,7 @@ public class AddRequestParameterRouteFilterIntegrationTests extends BaseWebClien @@ -70,6 +71,7 @@ public class AddRequestParameterRouteFilterIntegrationTests extends BaseWebClien
@EnableAutoConfiguration
@SpringBootConfiguration
@EnableGateway
public static class TestConfig { }
}

2
spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/route/RedirectToRouteFilterIntegrationTests.java

@ -22,6 +22,7 @@ import org.junit.runner.RunWith; @@ -22,6 +22,7 @@ import org.junit.runner.RunWith;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.gateway.EnableGateway;
import org.springframework.cloud.gateway.test.BaseWebClientTests;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
@ -62,6 +63,7 @@ public class RedirectToRouteFilterIntegrationTests extends BaseWebClientTests { @@ -62,6 +63,7 @@ public class RedirectToRouteFilterIntegrationTests extends BaseWebClientTests {
@EnableAutoConfiguration
@SpringBootConfiguration
@EnableGateway
public static class TestConfig { }
}

2
spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/route/RemoveNonProxyHeadersRouteFilterIntegrationTests.java

@ -24,6 +24,7 @@ import org.junit.runner.RunWith; @@ -24,6 +24,7 @@ import org.junit.runner.RunWith;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.gateway.EnableGateway;
import org.springframework.cloud.gateway.test.BaseWebClientTests;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
@ -68,6 +69,7 @@ public class RemoveNonProxyHeadersRouteFilterIntegrationTests extends BaseWebCli @@ -68,6 +69,7 @@ public class RemoveNonProxyHeadersRouteFilterIntegrationTests extends BaseWebCli
@EnableAutoConfiguration
@SpringBootConfiguration
@EnableGateway
public static class TestConfig { }
}

2
spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/route/RemoveRequestHeaderRouteFilterIntegrationTests.java

@ -24,6 +24,7 @@ import org.junit.runner.RunWith; @@ -24,6 +24,7 @@ import org.junit.runner.RunWith;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.gateway.EnableGateway;
import org.springframework.cloud.gateway.test.BaseWebClientTests;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
@ -62,6 +63,7 @@ public class RemoveRequestHeaderRouteFilterIntegrationTests extends BaseWebClien @@ -62,6 +63,7 @@ public class RemoveRequestHeaderRouteFilterIntegrationTests extends BaseWebClien
@EnableAutoConfiguration
@SpringBootConfiguration
@EnableGateway
public static class TestConfig { }
}

4
spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/route/RewritePathRouteFilterIntegrationTests.java

@ -22,14 +22,13 @@ import org.junit.runner.RunWith; @@ -22,14 +22,13 @@ import org.junit.runner.RunWith;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.gateway.EnableGateway;
import org.springframework.cloud.gateway.test.BaseWebClientTests;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.reactive.function.client.ClientResponse;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
import static org.springframework.cloud.gateway.test.TestUtils.assertStatus;
@ -59,6 +58,7 @@ public class RewritePathRouteFilterIntegrationTests extends BaseWebClientTests { @@ -59,6 +58,7 @@ public class RewritePathRouteFilterIntegrationTests extends BaseWebClientTests {
@EnableAutoConfiguration
@SpringBootConfiguration
@EnableGateway
public static class TestConfig { }
}

2
spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/route/SecureHeadersRouteFilterIntegrationTests.java

@ -22,6 +22,7 @@ import org.junit.runner.RunWith; @@ -22,6 +22,7 @@ import org.junit.runner.RunWith;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.gateway.EnableGateway;
import org.springframework.cloud.gateway.test.BaseWebClientTests;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
@ -78,6 +79,7 @@ public class SecureHeadersRouteFilterIntegrationTests extends BaseWebClientTests @@ -78,6 +79,7 @@ public class SecureHeadersRouteFilterIntegrationTests extends BaseWebClientTests
@EnableAutoConfiguration
@SpringBootConfiguration
@EnableGateway
public static class TestConfig { }
}

2
spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/route/SetPathRouteFilterIntegrationTests.java

@ -22,6 +22,7 @@ import org.junit.runner.RunWith; @@ -22,6 +22,7 @@ import org.junit.runner.RunWith;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.gateway.EnableGateway;
import org.springframework.cloud.gateway.test.BaseWebClientTests;
import org.springframework.http.HttpStatus;
import org.springframework.test.annotation.DirtiesContext;
@ -57,6 +58,7 @@ public class SetPathRouteFilterIntegrationTests extends BaseWebClientTests { @@ -57,6 +58,7 @@ public class SetPathRouteFilterIntegrationTests extends BaseWebClientTests {
@EnableAutoConfiguration
@SpringBootConfiguration
@EnableGateway
public static class TestConfig { }
}

2
spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/route/SetResponseRouteFilterIntegrationTests.java

@ -22,6 +22,7 @@ import org.junit.runner.RunWith; @@ -22,6 +22,7 @@ import org.junit.runner.RunWith;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.gateway.EnableGateway;
import org.springframework.cloud.gateway.test.BaseWebClientTests;
import org.springframework.http.HttpHeaders;
import org.springframework.test.annotation.DirtiesContext;
@ -59,6 +60,7 @@ public class SetResponseRouteFilterIntegrationTests extends BaseWebClientTests { @@ -59,6 +60,7 @@ public class SetResponseRouteFilterIntegrationTests extends BaseWebClientTests {
@EnableAutoConfiguration
@SpringBootConfiguration
@EnableGateway
public static class TestConfig { }
}

2
spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/route/SetStatusRouteFilterIntegrationTests.java

@ -22,6 +22,7 @@ import org.junit.runner.RunWith; @@ -22,6 +22,7 @@ import org.junit.runner.RunWith;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.gateway.EnableGateway;
import org.springframework.cloud.gateway.test.BaseWebClientTests;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
@ -68,6 +69,7 @@ public class SetStatusRouteFilterIntegrationTests extends BaseWebClientTests { @@ -68,6 +69,7 @@ public class SetStatusRouteFilterIntegrationTests extends BaseWebClientTests {
@EnableAutoConfiguration
@SpringBootConfiguration
@EnableGateway
public static class TestConfig { }
}

2
spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/test/BaseWebClientTests.java

@ -23,6 +23,7 @@ import org.apache.commons.logging.Log; @@ -23,6 +23,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Before;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.cloud.gateway.EnableGateway;
import org.springframework.cloud.gateway.api.Route;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.context.annotation.Bean;
@ -61,6 +62,7 @@ public class BaseWebClientTests { @@ -61,6 +62,7 @@ public class BaseWebClientTests {
}
@Configuration
@EnableGateway
protected static class DefaultTestConfig {
private static final Log log = LogFactory.getLog(DefaultTestConfig.class);

2
spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/test/FormIntegrationTests.java

@ -25,6 +25,7 @@ import org.junit.runner.RunWith; @@ -25,6 +25,7 @@ import org.junit.runner.RunWith;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.gateway.EnableGateway;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
@ -98,6 +99,7 @@ public class FormIntegrationTests extends BaseWebClientTests { @@ -98,6 +99,7 @@ public class FormIntegrationTests extends BaseWebClientTests {
@EnableAutoConfiguration
@SpringBootConfiguration
@EnableGateway
//@Import(DefaultTestConfig.class)
public static class TestConfig { }

2
spring-cloud-gateway-sample/src/main/java/org/springframework/cloud/gateway/sample/GatewaySampleApplication.java

@ -20,6 +20,7 @@ package org.springframework.cloud.gateway.sample; @@ -20,6 +20,7 @@ package org.springframework.cloud.gateway.sample;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.cloud.gateway.EnableGateway;
import org.springframework.cloud.gateway.api.RouteLocator;
import org.springframework.cloud.gateway.config.GatewayProperties;
import org.springframework.cloud.gateway.config.PropertiesRouteLocator;
@ -35,6 +36,7 @@ import reactor.core.publisher.Flux; @@ -35,6 +36,7 @@ import reactor.core.publisher.Flux;
*/
@SpringBootConfiguration
@EnableAutoConfiguration
@EnableGateway
public class GatewaySampleApplication {
@Bean
public PropertiesRouteLocator propertiesRouteLocator(GatewayProperties properties) {

Loading…
Cancel
Save