Spring Cloud - Zuul - Custom Filters

The Netflix Spring Cloud documentation does not contain any information about existing Zuul filters. Are there any other resources that explain existing zuul filters, guidelines for creating a new filter? I also need to know what priority should be set in my custom filter, and do I need to use ResponseWappers, for example, in servlet filters?

+1
source share
1 answer

To create a custom filter, you can extend the class with ZuulFilter and you will need to add @ Bean configuration.

public class MyFilter extends ZuulFilter {
    @Override
  public String filterType() {
    return "pre";
  }

  @Override
  public int filterOrder() {
    return 1;
  }

  @Override
  public boolean shouldFilter() {
    return true;
  }

  @Override
  public Object run() {
    return null;
  }
    }

, springbootapplication

@Bean
  public MyFilter myFilter() {
    return new MyFilter();
  }

4 PRE, ROUTING, POST, ERROR. , , FilterType() , .

RequestContext .

: -

+3

Source: https://habr.com/ru/post/1619375/


All Articles