Skip to content

Commit 2a6039f

Browse files
author
王俊杰
committed
update
1 parent 7e03ffe commit 2a6039f

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/main/java/com/baidu/disk/config/WebInterceptor.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,27 @@ public class WebInterceptor extends HandlerInterceptorAdapter {
3333
private LimitExcutor limitExcutor = new GuavaLimitExcutor();
3434

3535
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
36-
//限流2个维度
37-
//IP
38-
String identifier = IpUtil.getClientIp(request);
39-
//api维度
40-
String key = request.getRequestURI();
41-
String composeKey = KeyUtil.compositeKey(identifier, key);
42-
LimitEntity limitEntity = limitEntityMap.get(composeKey);
43-
if (limitEntity == null) {
44-
limitEntity = new LimitEntity();
45-
limitEntity.setIdentifier(identifier);
46-
limitEntity.setKey(key);
47-
limitEntity.setSeconds(2);
48-
limitEntity.setLimtNum(1);
49-
limitEntity.setLimitType(LimitType.USER_URL);
50-
limitEntityMap.putIfAbsent(composeKey, limitEntity);
51-
}
52-
53-
if (limitExcutor.tryAccess(limitEntity).getResultType() != LimitResult.ResultType.SUCCESS) {
54-
returnJson(response);
55-
return false;
56-
}
36+
// //限流2个维度
37+
// //IP
38+
// String identifier = IpUtil.getClientIp(request);
39+
// //api维度
40+
// String key = request.getRequestURI();
41+
// String composeKey = KeyUtil.compositeKey(identifier, key);
42+
// LimitEntity limitEntity = limitEntityMap.get(composeKey);
43+
// if (limitEntity == null) {
44+
// limitEntity = new LimitEntity();
45+
// limitEntity.setIdentifier(identifier);
46+
// limitEntity.setKey(key);
47+
// limitEntity.setSeconds(2);
48+
// limitEntity.setLimtNum(1);
49+
// limitEntity.setLimitType(LimitType.USER_URL);
50+
// limitEntityMap.putIfAbsent(composeKey, limitEntity);
51+
// }
52+
//
53+
// if (limitExcutor.tryAccess(limitEntity).getResultType() != LimitResult.ResultType.SUCCESS) {
54+
// returnJson(response);
55+
// return false;
56+
// }
5757

5858
return true;
5959
}

0 commit comments

Comments
 (0)