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

import com.muyu.cloud.common.saas.contents.SaaSConstant;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置
 *
 * @author muyu
 */
public class WebMvcSaaSConfig implements WebMvcConfigurer {


    /**
     * 添加请求拦截器配置
     * @param registry 拦截器注册表，用于注册自定义拦截器
     */
    @Override
    public void addInterceptors (InterceptorRegistry registry) {
        registry.addInterceptor(getHeaderInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns(SaaSConstant.EXCLUDE_URLS)
                .order(SaaSConstant.INTERCEPTOR_ORDER);
    }

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