Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add rejected_msg field to limit-req plugin form #2312

Merged
merged 3 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ context('Create and delete route with limit-req form', () => {
rate: '#rate',
burst: '#burst',
key: '#key',
rejected_msg: '#rejected_msg',
};

const data = {
Expand All @@ -42,6 +43,7 @@ context('Create and delete route with limit-req form', () => {
port: '80',
weight: 1,
key: 'remote_addr',
rejected_msg: 'Requests are too frequent, please try again later.',
};

beforeEach(() => {
Expand Down Expand Up @@ -92,6 +94,7 @@ context('Create and delete route with limit-req form', () => {
cy.get(selector.rate).type(1);
cy.get(selector.burst).type(0);
cy.get(selector.key).type(data.key);
cy.get(selector.rejected_msg).type(data.rejected_msg);
cy.get(selector.drawer).within(() => {
cy.contains('Submit').click({
force: true,
Expand Down
7 changes: 7 additions & 0 deletions web/src/components/Plugin/UI/limit-req.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ const LimitReq: React.FC<Props> = ({ form, schema }) => {
max={properties.rejected_code.maximum}
/>
</Form.Item>
<Form.Item
label="rejected_msg"
name="rejected_msg"
tooltip={formatMessage({ id: 'component.pluginForm.limit-req.rejected_msg.tooltip' })}
>
<Input />
</Form.Item>
<Form.Item
label="nodelay"
name="nodelay"
Expand Down
2 changes: 2 additions & 0 deletions web/src/components/Plugin/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ export default {
'component.pluginForm.limit-req.key.tooltip': 'The user specified key to limit the rate.',
'component.pluginForm.limit-req.rejected_code.tooltip':
'The HTTP status code returned when the request exceeds the threshold is rejected.',
'component.pluginForm.limit-req.rejected_msg.tooltip':
'The response body returned when the request exceeds the threshold is rejected.',
'component.pluginForm.limit-req.nodelay.tooltip':
'If nodelay flag is true, bursted requests will not get delayed',

Expand Down
1 change: 1 addition & 0 deletions web/src/components/Plugin/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export default {
'component.pluginForm.limit-req.key.tooltip': '用来做请求计数的依据',
'component.pluginForm.limit-req.rejected_code.tooltip':
'当请求超过阈值被拒绝时,返回的 HTTP 状态码。',
'component.pluginForm.limit-req.rejected_msg.tooltip': '当请求超过阈值被拒绝时,返回的响应体。',
'component.pluginForm.limit-req.nodelay.tooltip': '开启后突发的请求不会延迟',

'component.plugin.form': '表单',
Expand Down