springboot.sword.config.SpringWebConfig Maven / Gradle / Ivy
The newest version!
/*
* @(#)SpringWebConfig.java 2021-11-5
*
* Copyright (c) 2021. All Rights Reserved.
*
*/
package springboot.sword.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import com.github.javaclub.sword.web.interceptor.BasicAuthInterceptor;
import com.github.javaclub.sword.web.interceptor.MonitorHandlerInterceptor;
import com.github.javaclub.sword.web.interceptor.SystemDefaultInterceptor;
import com.github.javaclub.sword.web.interceptor.WebMdcHandlerInterceptor;
/**
* SpringWebConfig
*
* @author Gerald Chen
* @version $Id: SpringWebConfig.java 2021-11-5 11:05:27 Exp $
*/
@Configuration
public class SpringWebConfig implements WebMvcConfigurer {
private static final Logger log = LoggerFactory.getLogger(SpringWebConfig.class);
@Override
public void addInterceptors(InterceptorRegistry registry) {
// 全局默认拦截,主要处理404
registry.addInterceptor(new SystemDefaultInterceptor()).addPathPatterns("/**");
// 分布式链路追踪
registry.addInterceptor(new WebMdcHandlerInterceptor()).addPathPatterns("/**");
// perf-monitor
registry.addInterceptor(new MonitorHandlerInterceptor()).addPathPatterns("/**");
// 简单鉴权
registry.addInterceptor(new BasicAuthInterceptor()).addPathPatterns("/**");
}
}