Skip to content

Commit 3dd2cf4

Browse files
committed
修复拦截Swagger静态资源问题
1 parent 35f0962 commit 3dd2cf4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

api-boot-project/api-boot-plugins/api-boot-plugin-rate-limiter/src/main/java/org/minbox/framework/api/boot/plugin/rate/limiter/handler/ApiBootDefaultRateLimiterInterceptorHandler.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.springframework.util.ObjectUtils;
2626
import org.springframework.web.method.HandlerMethod;
2727
import org.springframework.web.servlet.HandlerInterceptor;
28+
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
2829

2930
import javax.servlet.http.HttpServletRequest;
3031
import javax.servlet.http.HttpServletResponse;
@@ -68,6 +69,10 @@ public ApiBootDefaultRateLimiterInterceptorHandler(ApiBootRateLimiter apiBootRat
6869
@Override
6970
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
7071
try {
72+
// Do not intercept resource requests
73+
if (handler instanceof ResourceHttpRequestHandler) {
74+
return true;
75+
}
7176
HandlerMethod handlerMethod = (HandlerMethod) handler;
7277
// get method declared RateLimiter
7378
RateLimiter rateLimiterAnnotation = handlerMethod.getMethodAnnotation(RateLimiter.class);

0 commit comments

Comments
 (0)