添加 拦截器方便调试

This commit is contained in:
zxb 2023-08-07 12:35:13 +08:00
parent 64a613cea6
commit a27be660fe
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,21 @@
package com.genersoft.iot.vmp.conf.security;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Slf4j
@Component
@SuppressWarnings({"unused"})
@RequiredArgsConstructor
public class RequestInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
log.info("访问 {}",request.getRequestURI());
return true;
}
}

View File

@ -0,0 +1,21 @@
package com.genersoft.iot.vmp.conf.security;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Slf4j
@Configuration
@RequiredArgsConstructor
public class WebConfig implements WebMvcConfigurer {
private final RequestInterceptor requestInterceptor;
@Override
public void addInterceptors(@NotNull InterceptorRegistry registry) {
registry.addInterceptor(requestInterceptor)
.excludePathPatterns("/index/hook/**")
.addPathPatterns("/**");
}
}