/*
 * 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.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.RouteDefinitionLocator;
import org.springframework.cloud.gateway.config.GatewayProperties;
import org.springframework.cloud.gateway.config.PropertiesRouteDefinitionLocator;
import org.springframework.cloud.gateway.support.CachingRouteDefinitionLocator;
import org.springframework.cloud.gateway.support.CompositeRouteDefinitionLocator;
import org.springframework.cloud.gateway.support.InMemoryRouteDefinitionRepository;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import reactor.core.publisher.Flux;

/**
 * @author Spencer Gibb
 */
@SpringBootConfiguration
@EnableAutoConfiguration
@EnableGateway
public class GatewaySampleApplication {

	public static void main(String[] args) {
		SpringApplication.run(GatewaySampleApplication.class, args);
	}
}

@@ -669,16 +669,40 @@
 ample;%0A%0A
+import java.util.List;%0A%0A
 import o
@@ -973,27 +973,19 @@
 way.
-api
+route
 .Route
-Definition
 Loca
@@ -1034,32 +1034,27 @@
 way.
-config.GatewayProperties
+filter.GlobalFilter
 ;%0Aim
@@ -1096,47 +1096,56 @@
 way.
-config.PropertiesRouteDefinitionLoca
+filter.factory.AddResponseHeaderWebFilterFac
 tor
+y
 ;%0Aim
@@ -1187,272 +1187,203 @@
 way.
-support.CachingRouteDefinitionLocator;%0Aimport org.springframework.cloud.gateway.support.CompositeRouteDefinitionLocator;%0Aimport org.springframework.cloud.gateway.support.InMemoryRouteDefinitionRepository;%0Aimport org.springframework.context.annotation.Bean;
+route.Route;%0Aimport org.springframework.context.annotation.Bean;%0Aimport org.springframework.tuple.TupleBuilder;%0Aimport org.springframework.web.reactive.function.server.RequestPredicates;%0A
 %0Aimport 
 org.
@@ -1370,32 +1370,39 @@
 icates;%0A%0Aimport 
+static 
 org.springframew
@@ -1410,34 +1410,70 @@
 rk.c
-ontext.annotation.Primary;
+loud.gateway.support.RouteDefinitionRouteLocator.loadFilters;%0A
 %0Aimp
@@ -1644,16 +1644,488 @@
 tion %7B%0A%0A
+%09@Bean%0A%09public RouteLocator customRouteLocator(List%3CGlobalFilter%3E globalFilters) %7B%0A%09%09return () -%3E %7B%0A%09%09%09Route route = Route.builder()%0A%09%09%09%09%09.id(%22test%22)%0A%09%09%09%09%09.uri(%22http://httpbin.org:80%22)%0A%09%09%09%09%09.requestPredicate(RequestPredicates.path(%22/image/png%22))%0A%09%09%09%09%09.addAll(loadFilters(globalFilters))%0A%09%09%09%09%09.add(new AddResponseHeaderWebFilterFactory()%0A%09%09%09%09%09%09%09.apply(TupleBuilder.tuple().of(%22name%22, %22X-TestHeader%22, %22value%22, %22foobar%22)))%0A%09%09%09%09%09.build();%0A%09%09%09return Flux.just(route);%0A%09%09%7D;%0A%09%7D%0A%0A
 %09public 

Add programmatic RouteLocator example