package com.repair.core;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class JwtlnterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //region
        //目前测试下来 使用 /**所有的话，response.sendError浏览器获取不到响应的信息
        //默认拦截所有路径
        registry.addInterceptor(authenticationInterceptor())
                .addPathPatterns("/api/**");
        //endregion
    }

    @Bean
    public HandlerInterceptor authenticationInterceptor() {
        return new JwtAuthenticationInterceptor();
    }
}
