package com.muyu.cloud.common.saas.interceptor;

import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置
 *
 * @author muyu
 */
public class WebMvcSaaSConfig implements WebMvcConfigurer {
    /**
     * 不需要拦截的地址
     */
    public static final String[] EXCLUDE_URLS = {"/user/info", "/login", "/logout", "/refresh"};

    @Override
    public void addInterceptors (InterceptorRegistry registry) {
        registry.addInterceptor(getHeaderInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns(EXCLUDE_URLS)
                .order(-10);
    }

    /**
     * 自定义请求头拦截器
     */
    public SaaSInterceptor getHeaderInterceptor () {
        return new SaaSInterceptor();
    }
}
