title: How to Specify custom filter in application.yml Spring Cloud Gateway
body: <p>I have a custom gateway filter MYGatewayFilter.java file now i want to use this gateway filter with my route written in application.yml</p>
  
  <pre><code> spring:
    cloud:
     gateway:
      routes:
        - id: login2_route
        uri: http://127.0.0.1:8083/login
        predicates:
         - Path: /login/
        filters:
  </code></pre>
  
  <p>How do i define filters for above route   </p>
  
  <p>Custom Filter MyGatewayFilter.java</p>
  
  <pre><code>public class MyGatewayFilter implements GatewayFilter {
      @Override
    public Mono&lt;Void&gt; filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        ServerHttpRequest request;
        if(request.getHeaders().get("x-mydata")!=null){
           request= exchange.getRequest().mutate().header("my-new-header",request.getHeaders().get("x-mydata").get(0)).build();
        }
  
        return chain.filter(exchange.mutate().request(request).build());
    }
  }       
  </code></pre>