Add three kinds of limit counter mode, and two kinds of response mode for quota exceeded response. #492
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
1.RateLimitRule adds the ConterKeyMode property. Below is the effect of its value.
Let's say the EndPoint is set to *:/api/values
VerbAndPath (default, compatible with older versions) - GET:/api/values/1 and POST:/api/values/1, GET:/api/values/2 and POST:/api/values/2 will be counted separately.
Path-GET :/api/values and POST:/api/values will be combined and counted
VerbAndRule-GET :/api/values/1 POST:/api/values/2 will be counted separately, but GET:/api/values/1 and GET:/api/values/2 will be counted together.
Rule-GET :/api/values/1, POST:/api/values/1, GET:/api/values/2, POST:/api/values/2 will all be concatenated.
2. Increase ResponseType QuotaExceededResponse, Controller, Action, Url attribute. Depending on the value of ResponseType, different properties are used to respond to different outputs.
WriteContent (default, older compatible) - StatusCode writes Content to the response stream based on ContentType.
RedirectToAction (must set IApplicationBuilder UseRouting(), IApplicationBuilder. UseEndpoints() first) - redirects to the specified Controller. The Action. QuotaExceededParams quotaExceededParams can be obtained from the parameters to output the results with a more customized response.
RedirectToUrl - Redirects to the specified Url. Low custom response, cannot get QuotaExceededParams quotaExceededParams. Suitable for developers who just need to beautification their pages.
3. Add relevant unit tests.