package com.dgtly.apiframework.config;

import com.dgtly.apiframework.filter.BodyReaderFilter;
import com.dgtly.common.utils.StringUtils;
import com.dgtly.common.xss.XssFilter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.stereotype.Component;

import javax.servlet.DispatcherType;
import java.util.HashMap;
import java.util.Map;

/**
 * Filter配置
 *
 * @author ruoyi
 */
@Configuration
public class ApiFilterConfig
{
    /**
     * 配置过滤器，防止在拦截器中读取参数校验后controller中不能再次获取body参数
     * @return
     */
   @Bean
    public FilterRegistrationBean registerBodyReaderFilter() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new BodyReaderFilter());
        registration.addUrlPatterns("/**");
        registration.setName("bodyReaderFilter");
        registration.setOrder(1);  //值越小，Filter越靠前。
        return registration;
    }
}
