org.springframework.cloud.gateway.config.GatewayProperties Java Examples

The following examples show how to use org.springframework.cloud.gateway.config.GatewayProperties. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RouteDefinitionRouteLocator.java    From spring-cloud-gateway with Apache License 2.0 5 votes vote down vote up
public RouteDefinitionRouteLocator(RouteDefinitionLocator routeDefinitionLocator,
		List<RoutePredicateFactory> predicates,
		List<GatewayFilterFactory> gatewayFilterFactories,
		GatewayProperties gatewayProperties,
		ConfigurationService configurationService) {
	this.routeDefinitionLocator = routeDefinitionLocator;
	this.configurationService = configurationService;
	initFactories(predicates);
	gatewayFilterFactories.forEach(
			factory -> this.gatewayFilterFactories.put(factory.name(), factory));
	this.gatewayProperties = gatewayProperties;
}
 
Example #2
Source File: RouteDefinitionRouteLocatorTests.java    From spring-cloud-gateway with Apache License 2.0 5 votes vote down vote up
@Test
public void contextLoads() {
	List<RoutePredicateFactory> predicates = Arrays
			.asList(new HostRoutePredicateFactory());
	List<GatewayFilterFactory> gatewayFilterFactories = Arrays.asList(
			new RemoveResponseHeaderGatewayFilterFactory(),
			new AddResponseHeaderGatewayFilterFactory(),
			new TestOrderedGatewayFilterFactory());
	GatewayProperties gatewayProperties = new GatewayProperties();
	gatewayProperties.setRoutes(Arrays.asList(new RouteDefinition() {
		{
			setId("foo");
			setUri(URI.create("https://foo.example.com"));
			setPredicates(
					Arrays.asList(new PredicateDefinition("Host=*.example.com")));
			setFilters(Arrays.asList(
					new FilterDefinition("RemoveResponseHeader=Server"),
					new FilterDefinition("TestOrdered="),
					new FilterDefinition("AddResponseHeader=X-Response-Foo, Bar")));
		}
	}));

	PropertiesRouteDefinitionLocator routeDefinitionLocator = new PropertiesRouteDefinitionLocator(
			gatewayProperties);
	@SuppressWarnings("deprecation")
	RouteDefinitionRouteLocator routeDefinitionRouteLocator = new RouteDefinitionRouteLocator(
			new CompositeRouteDefinitionLocator(Flux.just(routeDefinitionLocator)),
			predicates, gatewayFilterFactories, gatewayProperties,
			new ConfigurationService(null, () -> null, () -> null));

	StepVerifier.create(routeDefinitionRouteLocator.getRoutes()).assertNext(route -> {
		List<GatewayFilter> filters = route.getFilters();
		assertThat(filters).hasSize(3);
		assertThat(getFilterClassName(filters.get(0)))
				.contains("RemoveResponseHeader");
		assertThat(getFilterClassName(filters.get(1))).contains("AddResponseHeader");
		assertThat(getFilterClassName(filters.get(2)))
				.contains("RouteDefinitionRouteLocatorTests$TestOrderedGateway");
	}).expectComplete().verify();
}
 
Example #3
Source File: RouteDefinitionRouteLocatorTests.java    From spring-cloud-gateway with Apache License 2.0 5 votes vote down vote up
@Test
public void contextLoadsWithErrorRecovery() {
	List<RoutePredicateFactory> predicates = Arrays
			.asList(new HostRoutePredicateFactory());
	List<GatewayFilterFactory> gatewayFilterFactories = Arrays.asList(
			new RemoveResponseHeaderGatewayFilterFactory(),
			new AddResponseHeaderGatewayFilterFactory(),
			new TestOrderedGatewayFilterFactory());
	GatewayProperties gatewayProperties = new GatewayProperties();
	gatewayProperties.setRoutes(containsInvalidRoutes());
	gatewayProperties.setFailOnRouteDefinitionError(false);

	PropertiesRouteDefinitionLocator routeDefinitionLocator = new PropertiesRouteDefinitionLocator(
			gatewayProperties);
	@SuppressWarnings("deprecation")
	RouteDefinitionRouteLocator routeDefinitionRouteLocator = new RouteDefinitionRouteLocator(
			new CompositeRouteDefinitionLocator(Flux.just(routeDefinitionLocator)),
			predicates, gatewayFilterFactories, gatewayProperties,
			new ConfigurationService(null, () -> null, () -> null));

	StepVerifier.create(routeDefinitionRouteLocator.getRoutes()).assertNext(route -> {
		List<GatewayFilter> filters = route.getFilters();
		assertThat(filters).hasSize(3);
		assertThat(getFilterClassName(filters.get(0)))
				.contains("RemoveResponseHeader");
		assertThat(getFilterClassName(filters.get(1))).contains("AddResponseHeader");
		assertThat(getFilterClassName(filters.get(2)))
				.contains("RouteDefinitionRouteLocatorTests$TestOrderedGateway");
	}).expectComplete().verify();
}
 
Example #4
Source File: GatewaySwaggerProvider.java    From open-capacity-platform with Apache License 2.0 4 votes vote down vote up
public GatewaySwaggerProvider(RouteLocator routeLocator, GatewayProperties gatewayProperties) {
    this.routeLocator = routeLocator;
    this.gatewayProperties = gatewayProperties;
}
 
Example #5
Source File: FebsDocGatewayResourceConfigure.java    From FEBS-Cloud with Apache License 2.0 4 votes vote down vote up
public FebsDocGatewayResourceConfigure(RouteLocator routeLocator, GatewayProperties gatewayProperties) {
    this.routeLocator = routeLocator;
    this.gatewayProperties = gatewayProperties;
}
 
Example #6
Source File: FebsDocGatewayAutoConfigure.java    From FEBS-Cloud with Apache License 2.0 4 votes vote down vote up
@Bean
public FebsDocGatewayResourceConfigure febsDocGatewayResourceConfigure(RouteLocator routeLocator, GatewayProperties gatewayProperties) {
    return new FebsDocGatewayResourceConfigure(routeLocator, gatewayProperties);
}
 
Example #7
Source File: SwaggerProvider.java    From microservices-platform with Apache License 2.0 4 votes vote down vote up
public SwaggerProvider(RouteLocator routeLocator, GatewayProperties gatewayProperties) {
    this.routeLocator = routeLocator;
    this.gatewayProperties = gatewayProperties;
}