Baoyuantop commented on code in PR #12573: URL: https://github.com/apache/apisix/pull/12573#discussion_r2314744022
########## docs/zh/latest/plugins/request-id.md: ########## @@ -239,6 +239,59 @@ curl -i "http://127.0.0.1:9080/anything" X-Request-Id: kepgHWCH2ycQ6JknQKrX2 ``` +### 使用 `ksuid` 算法 + +以下示例演示如何在路由上配置 `request-id` 并使用 `ksuid` 算法生成请求 ID。 + +使用 `request-id` 插件创建路由,如下所示: + +```shell +curl "http://127.0.0.1:9180/apisix/admin/routes" -X PUT \ + -H "X-API-KEY: ${ADMIN_API_KEY}" \ + -d '{ + "id": "request-id-route", + "uri": "/anything", + "plugins": { + "request-id": { + "algorithm": "ksuid" + } + }, + "upstream": { + "type": "roundrobin", + "nodes": { + "httpbin.org:80": 1 + } + } + }' +``` + +向路由发送请求: + +```shell +curl -i "http://127.0.0.1:9080/anything" +``` + +您应该收到一个 `HTTP/1.1 200 OK` 响应,并看到响应包含 `X-Req-Identifier` 标头,其中的 ID 使用 `ksuid` 算法生成: Review Comment: It should be X-Request-Id not X-Req-Identifier ########## apisix/plugins/request-id.lua: ########## @@ -32,7 +33,7 @@ local schema = { include_in_response = {type = "boolean", default = true}, algorithm = { type = "string", - enum = {"uuid", "nanoid", "range_id"}, + enum = {"uuid", "nanoid", "range_id","ksuid"}, Review Comment: ```suggestion enum = {"uuid", "nanoid", "range_id", "ksuid"}, ``` -- 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: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org