@@ -33,27 +33,27 @@ public class WebInterceptor extends HandlerInterceptorAdapter {
33
33
private LimitExcutor limitExcutor = new GuavaLimitExcutor ();
34
34
35
35
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
+ // }
57
57
58
58
return true ;
59
59
}
0 commit comments