package org.springblade.common.config;

import liquibase.pro.packaged.I;
import org.springblade.common.interceptor.IPInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author: Silent
 * @Description
 * @Date: Created in 17:16 2021/11/16
 * @Modified By:
 */
@Configuration
public class BladeMvcConfiguration implements WebMvcConfigurer {
	@Bean
	public IPInterceptor ipInterceptor(){
		return new IPInterceptor();
	}

	/**
	 * 添加拦截器
	 * @param registry
	 */
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		//添加拦截器
		InterceptorRegistration interceptorRegistration = registry.addInterceptor(ipInterceptor());
		interceptorRegistration.addPathPatterns("/**");
	}
}
