Skip to content

Commit 6291a2c

Browse files
committed
流量溢出响应实体示例
1 parent a0e79ed commit 6291a2c

File tree

1 file changed

+41
-0
lines changed
  • api-boot-samples/api-boot-sample-rate-limiter/src/main/java/org/minbox/framework/api/boot/sample

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright [2019] [恒宇少年 - 于起宇]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
package org.minbox.framework.api.boot.sample;
19+
20+
import org.minbox.framework.api.boot.common.model.ApiBootResult;
21+
import org.minbox.framework.api.boot.plugin.rate.limiter.result.RateLimiterOverFlowResponse;
22+
import org.springframework.stereotype.Component;
23+
24+
/**
25+
* 自定义流量溢出后响应的实体格式
26+
*
27+
* @author:恒宇少年 - 于起宇
28+
* <p>
29+
* DateTime:2019-05-25 16:21
30+
* Blog:http://blog.yuqiyu.com
31+
* WebSite:http://www.jianshu.com/u/092df3f77bca
32+
* Gitee:https://gitee.com/hengboy
33+
* GitHub:https://github.com/hengboy
34+
*/
35+
@Component
36+
public class CustomerResponse implements RateLimiterOverFlowResponse {
37+
@Override
38+
public Object overflow(Object[] methodArgs) {
39+
return ApiBootResult.builder().errorCode("REQUEST_OVER_FLOW").errorMessage("流量被限制.").build();
40+
}
41+
}

0 commit comments

Comments
 (0)