Skip to content

Commit 6d2445e

Browse files
authored
fix: add rejected_msg field to limit-count plugin form (#2328)
1 parent 46c56f4 commit 6d2445e

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

web/cypress/integration/route/create-route-with-limit-count-plugin-form.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ context('Create and delete route with limit-count form', () => {
3535
redis_timeout: '#time_window',
3636
key: '#key',
3737
rejected_code: '#rejected_code',
38+
rejected_msg: '#rejected_msg',
3839
policy: '#policy',
3940
group: '#group',
4041
redis_host: '#redis_host',
@@ -52,6 +53,7 @@ context('Create and delete route with limit-count form', () => {
5253
submitSuccess: 'Submit Successfully',
5354
port: '80',
5455
weight: 1,
56+
rejected_msg: 'Requests are too frequent, please try again later.',
5557
redisClusterName: 'Please Enter redis_cluster_name',
5658
redisClusterNode: 'Please Enter redis_cluster_node',
5759
};
@@ -86,6 +88,7 @@ context('Create and delete route with limit-count form', () => {
8688
cy.get(selector.count).type(1);
8789
cy.get(selector.time_window).type(1);
8890
cy.get(selector.rejected_code).type(500);
91+
cy.get(selector.rejected_msg).type(data.rejected_msg);
8992
cy.get(selector.group).type('test_group');
9093
cy.get(selector.drawer).within(() => {
9194
cy.contains('Submit').click({

web/src/components/Plugin/UI/limit-count.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,13 @@ const LimitCount: React.FC<Props> = ({ form, schema }) => {
305305
max={properties.rejected_code.maximum}
306306
/>
307307
</Form.Item>
308+
<Form.Item
309+
label="rejected_msg"
310+
name="rejected_msg"
311+
tooltip={formatMessage({ id: 'component.pluginForm.limit-req.rejected_msg.tooltip' })}
312+
>
313+
<Input />
314+
</Form.Item>
308315
<Form.Item
309316
initialValue={policy}
310317
label="policy"

web/src/components/Plugin/locales/en-US.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ export default {
130130
'component.pluginForm.limit-count.key.tooltip': 'The user specified key to limit the count.',
131131
'component.pluginForm.limit-count.rejected_code.tooltip':
132132
'The HTTP status code returned when the request exceeds the threshold is rejected, default 503.',
133+
'component.pluginForm.limit-count.rejected_msg.tooltip':
134+
'The response body returned when the request exceeds the threshold is rejected.',
133135
'component.pluginForm.limit-count.policy.tooltip':
134136
'The rate-limiting policies to use for retrieving and incrementing the limits. Available values are local(the counters will be stored locally in-memory on the node) and redis(counters are stored on a Redis server and will be shared across the nodes, usually use it to do the global speed limit) and redis-cluster(the same function as redis, only use Redis cluster pattern).',
135137
'component.pluginForm.limit-count.allow_degradation.tooltip':

web/src/components/Plugin/locales/zh-CN.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export default {
122122
'用来做请求计数的有效值。例如,可以使用主机名(或服务器区域)作为关键字,以便限制每个主机名规定时间内的请求次数。我们也可以使用客户端地址作为关键字,这样我们就可以避免单个客户端规定时间内多次的连接我们的服务。',
123123
'component.pluginForm.limit-count.rejected_code.tooltip':
124124
'当请求超过阈值被拒绝时,返回的 HTTP 状态码。',
125+
'component.pluginForm.limit-count.rejected_msg.tooltip': '当请求超过阈值被拒绝时,返回的响应体。',
125126
'component.pluginForm.limit-count.policy.tooltip':
126127
'用于检索和增加限制的速率限制策略。可选的值有:local(计数器被以内存方式保存在节点本地,默认选项) 和 redis(计数器保存在 Redis 服务节点上,从而可以跨节点共享结果,通常用它来完成全局限速);以及redis-cluster,跟 redis 功能一样,只是使用 redis 集群方式。',
127128
'component.pluginForm.limit-count.allow_degradation.tooltip':

0 commit comments

Comments
 (0)