package com.lantone.interceptor.config;

import com.lantone.interceptor.interceptor.HttpInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * @Description:
 * @Author songxl
 * @Date 2021/9/26
 */
@PropertySource("classpath:application.properties")
@Configuration
public class HttpInterceptorConfig implements WebMvcConfigurer, EnvironmentAware {
    @Autowired
    private HttpInterceptor httpInterceptor;
    private Environment env;

    @Override
    public void setEnvironment(Environment environment) {
        this.env=environment;
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(httpInterceptor).addPathPatterns("/**")
                .excludePathPatterns(env.getProperty("url",List.class));

    }
}
