minbox-projects/api-boot

logging的ignorePaths可以支持正则表达式

Closed this issue · 2 comments

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
api排除拦截现在都要写完成路径才行 类似的 /index /index/112 如果我要排除 /index开头的所有的api不好写 可以考虑做类似下面的操作
ignore-paths: - /index/*

Describe the solution you'd like
A clear and concise description of what you want to happen.
使用正则匹配应该是比较不错的

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.
在filter或拦截器里做类似的:

public class ParamFilter implements Filter {

    private PrintParamProperties properties;

    public ParamFilter(PrintParamProperties properties) {
        this.properties = properties;
    }
    @Override
    public void doFilter(ServletRequest request, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        if (properties == null) {
            properties = new PrintParamProperties();
        }
        HttpServletRequest r = (HttpServletRequest) request;

        if (isRequestExcluded(r)) {
            filterChain.doFilter(request, servletResponse);
}
 private boolean isRequestExcluded(HttpServletRequest httpRequest) {
        return Objects.nonNull(this.properties.getFilterExcludePattern())
                && Pattern.compile(this.properties.getFilterExcludePattern())
                .matcher(httpRequest.getRequestURI().substring(httpRequest.getContextPath().length()))
                .matches();
    }
}

@qinkangdeid 好的,感谢你的建议,会在2.1.3版本发布时添加上

目前ApiBoot已支持Ant风格排除上报路径配置,详见ApiBootLoggingInterceptor类内checkIgnore方法