Skip to content

Commit 78a8795

Browse files
committed
Merge pull request #295 from apinf/feature/ratelimit-field
Feature/ratelimit field
2 parents a8e8fe2 + 2ab1153 commit 78a8795

File tree

2 files changed

+39
-26
lines changed

2 files changed

+39
-26
lines changed

both/collections/backend.js

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -78,31 +78,10 @@ ApiBackendsSchema = new SimpleSchema({
7878
type: String,
7979
regEx: /^[a-z0-9A-Z_]{3,15}$/
8080
},
81-
duration: {
82-
type: Number,
83-
optional: true,
84-
label: 'Duration'
85-
},
86-
accuracy:{
87-
type: Number,
88-
optional: true
89-
},
90-
limit_by: {
91-
type: String,
92-
optional: true
93-
},
94-
limit: {
95-
type: Number,
96-
optional: true
97-
},
9881
distributed: {
9982
type: Boolean,
10083
optional: true
10184
},
102-
response_headers: {
103-
type: Boolean,
104-
optional: true
105-
},
10685
matcher_type: {
10786
type: String,
10887
optional: true
@@ -227,8 +206,43 @@ ApiBackendsSchema = new SimpleSchema({
227206
'Custom rate limits',
228207
'Unlimited requests'
229208
],
230-
label: 'Rate limit'
231209
},
210+
211+
custom_rate_limits: {
212+
type: [Object],
213+
optional: true
214+
},
215+
"custom_rate_limits.$.duration": {
216+
type: String,
217+
optional: true
218+
},
219+
"custom_rate_limits.$.accuracy": {
220+
type: Number,
221+
optional: true,
222+
allowedValues: [
223+
'Seconds',
224+
'Minutes',
225+
'Hours'
226+
]
227+
},
228+
"custom_rate_limits.$.limit_by": {
229+
type: String,
230+
optional: true,
231+
allowedValues: [
232+
'API key',
233+
'IP Address'
234+
]
235+
},
236+
"custom_rate_limits.$.limit": {
237+
type: Number,
238+
optional: true,
239+
label: 'Number of requests',
240+
},
241+
242+
"custom_rate_limits.$.response_headers": {
243+
type: Boolean,
244+
optional: true
245+
},
232246
anonymous_rate_limit_behavior: {
233247
type: String,
234248
optional: true

client/views/api_backends/api_backends.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ <h4>Global Request Settings</h4>
4646
{{> afQuickField name='pass_api_key_header'}}
4747
{{> afQuickField name='pass_api_key_query_param'}}
4848
{{> afQuickField name='rate_limit_mode' options="allowed"}}
49-
{{> afQuickField name='duration'}}
50-
{{> afQuickField name='accuracy'}}
51-
{{> afQuickField name='limit_by'}}
52-
{{> afQuickField name='limit'}}
49+
{{#if afFieldValueIs name='rate_limit_mode' value="Custom rate limits"}}
50+
{{> afQuickField name='custom_rate_limits'}}
51+
{{/if}}
5352
<h4>Sub-URL Request Settings</h4>
5453
<hr />
5554
<span class="help-block">Change settings for specific sub-URLs within this API.</span>

0 commit comments

Comments
 (0)