Copilot commented on code in PR #13171:
URL: https://github.com/apache/apisix/pull/13171#discussion_r3056578683


##########
docs/en/latest/plugins/limit-count.md:
##########
@@ -410,7 +410,7 @@ Send the same request to a different APISIX instance within 
the same 30-second t
 
 ### Rate Limit with Anonymous Consumer
 
-does not need to authenticate and has less quotas. While this example uses 
[`key-auth`](./key-auth.md) for authentication, the anonymous Consumer can also 
be configured with [`basic-auth`](./basic-auth.md), 
[`jwt-auth`](./jwt-auth.md), and [`hmac-auth`](./hmac-auth.md).
+The following example demonstrates how you can configure different rate 
limiting policies for regular and anonymous Consumers, where the anonymous 
Consumer does not need to authenticate and has less quota. While this example 
uses [`key-auth`](./key-auth.md) for authentication, the anonymous Consumer can 
also be configured with [`basic-auth`](./basic-auth.md), 
[`jwt-auth`](./jwt-auth.md), and [`hmac-auth`](./hmac-auth.md).

Review Comment:
   Grammar: “has less quota” is awkward in English. Consider changing to “has a 
smaller quota” / “has a lower quota” (or similar) to read naturally.
   ```suggestion
   The following example demonstrates how you can configure different rate 
limiting policies for regular and anonymous Consumers, where the anonymous 
Consumer does not need to authenticate and has a lower quota. While this 
example uses [`key-auth`](./key-auth.md) for authentication, the anonymous 
Consumer can also be configured with [`basic-auth`](./basic-auth.md), 
[`jwt-auth`](./jwt-auth.md), and [`hmac-auth`](./hmac-auth.md).
   ```



##########
docs/en/latest/plugins/limit-count.md:
##########
@@ -512,3 +512,59 @@ You should see the following response, showing that only 
one request was success
 ```text
 200:    1, 429:    4
 ```
+
+### Customize Rate Limiting Headers
+
+The following example demonstrates how you can use Plugin metadata to 
customize the rate limiting response header names, which are by default 
`X-RateLimit-Limit`, `X-RateLimit-Remaining`, and `X-RateLimit-Reset`.
+
+Configure Plugin metadata to customize rate limiting headers:
+
+```shell
+curl "http://127.0.0.1:9180/apisix/admin/plugin_metadata/limit-count"; -X PUT \
+  -H "X-API-KEY: ${admin_key}" \
+  -d '{
+    "limit_header": "X-Custom-RateLimit-Limit",
+    "remaining_header": "X-Custom-RateLimit-Remaining",
+    "reset_header": "X-Custom-RateLimit-Reset"
+  }'

Review Comment:
   These new Admin API curl examples don’t set `Content-Type: 
application/json`. If the Admin API expects JSON, curl may default to 
`application/x-www-form-urlencoded` and the request can fail or be parsed 
unexpectedly. Add `-H 'Content-Type: application/json'` to the request headers 
(and mirror this change in the Chinese doc).



##########
docs/en/latest/plugins/limit-count.md:
##########
@@ -512,3 +512,59 @@ You should see the following response, showing that only 
one request was success
 ```text
 200:    1, 429:    4
 ```
+
+### Customize Rate Limiting Headers
+
+The following example demonstrates how you can use Plugin metadata to 
customize the rate limiting response header names, which are by default 
`X-RateLimit-Limit`, `X-RateLimit-Remaining`, and `X-RateLimit-Reset`.
+
+Configure Plugin metadata to customize rate limiting headers:
+
+```shell
+curl "http://127.0.0.1:9180/apisix/admin/plugin_metadata/limit-count"; -X PUT \
+  -H "X-API-KEY: ${admin_key}" \
+  -d '{
+    "limit_header": "X-Custom-RateLimit-Limit",
+    "remaining_header": "X-Custom-RateLimit-Remaining",
+    "reset_header": "X-Custom-RateLimit-Reset"
+  }'
+```
+
+Create a Route with `limit-count` Plugin:
+
+```shell
+curl "http://127.0.0.1:9180/apisix/admin/routes"; -X PUT \
+  -H "X-API-KEY: ${admin_key}" \
+  -d '{
+    "id": "limit-count-route",
+    "uri": "/get",
+    "plugins": {
+      "limit-count": {
+        "count": 1,
+        "time_window": 30,
+        "rejected_code": 429,
+        "key_type": "var",
+        "key": "remote_addr"
+      }
+    },
+    "upstream": {
+      "type": "roundrobin",
+      "nodes": {
+        "httpbin.org:80": 1
+      }
+    }
+  }'
+```
+
+Send a request to verify:
+
+```shell
+curl -i "http://127.0.0.1:9080/get";
+```
+
+You should receive an `HTTP/1.1 200 OK` response and see the following headers:
+

Review Comment:
   `X-*-Reset` is typically time-dependent (e.g., seconds until reset) so a 
fixed value like `28` can be misleading/non-reproducible. Consider documenting 
it as an example (e.g., `<seconds>`), or note that the value varies depending 
on when the request is made within the window (same applies to the Chinese doc).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to