This is an automated email from the ASF dual-hosted git repository.

traky pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 9f4a75d68 docs: improve `request-id` plugin docs (#11931)
9f4a75d68 is described below

commit 9f4a75d68c517a8c18ed41c492ab75e5e0382c23
Author: Traky Deng <[email protected]>
AuthorDate: Mon Mar 31 10:07:52 2025 +0800

    docs: improve `request-id` plugin docs (#11931)
    
    Co-authored-by: Yilia Lin <[email protected]>
---
 docs/en/latest/plugins/request-id.md | 268 +++++++++++++++++++++++++++++------
 docs/zh/latest/plugins/request-id.md | 261 ++++++++++++++++++++++++++++------
 2 files changed, 443 insertions(+), 86 deletions(-)

diff --git a/docs/en/latest/plugins/request-id.md 
b/docs/en/latest/plugins/request-id.md
index bc7b4ee1b..3f5fb398b 100644
--- a/docs/en/latest/plugins/request-id.md
+++ b/docs/en/latest/plugins/request-id.md
@@ -4,7 +4,7 @@ keywords:
   - Apache APISIX
   - API Gateway
   - Request ID
-description: This document describes information about the Apache APISIX 
request-id Plugin, you can use it to track API requests by adding a unique ID 
to each request.
+description: The request-id Plugin adds a unique ID to each request proxied 
through APISIX, which can be used to track API requests.
 ---
 
 <!--
@@ -26,33 +26,31 @@ description: This document describes information about the 
Apache APISIX request
 #
 -->
 
-## Description
-
-The `request-id` Plugin adds a unique ID to each request proxied through 
APISIX.
-
-This Plugin can be used to track API requests.
+<head>
+  <link rel="canonical" href="https://docs.api7.ai/hub/request-id"; />
+</head>
 
-:::note
+## Description
 
-The Plugin will not add a unique ID if the request already has a header with 
the configured `header_name`.
-
-:::
+The `request-id` Plugin adds a unique ID to each request proxied through 
APISIX, which can be used to track API requests. If a request carries an ID in 
the header corresponding to `header_name`, the Plugin will use the header value 
as the unique ID and will not overwrite with the automatically generated ID.
 
 ## Attributes
 
 | Name                | Type    | Required | Default        | Valid values     
               | Description                                                    
        |
 | ------------------- | ------- | -------- | -------------- | 
------------------------------- | 
---------------------------------------------------------------------- |
-| header_name         | string  | False    | "X-Request-Id" |                  
               | Header name for the unique request ID.                         
        |
-| include_in_response | boolean | False    | true           |                  
               | When set to `true`, adds the unique request ID in the response 
header. |
-| algorithm           | string  | False    | "uuid"         | ["uuid", 
"nanoid", "range_id"] | Algorithm to use for generating the unique request ID.  
               |
-| range_id.char_set      | string | False | 
"abcdefghijklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ0123456789| The minimum 
string length is 6 | Character set for range_id |
-| range_id.length    | integer | False | 16             | Minimum 6 | Id 
length for range_id algorithm |
+| header_name         | string  | False    | "X-Request-Id" |                  
               | Name of the header that carries the request unique ID. Note 
that if a request carries an ID in the `header_name` header, the Plugin will 
use the header value as the unique ID and will not overwrite it with the 
generated ID.                                 |
+| include_in_response | boolean | False    | true           |                  
               | If true, include the generated request ID in the response 
header, where the name of the header is the `header_name` value. |
+| algorithm           | string  | False    | "uuid"         | 
["uuid","nanoid","range_id"] | Algorithm used for generating the unique ID. 
When set to `uuid` , the Plugin generates a universally unique identifier. When 
set to `nanoid`, the Plugin generates a compact, URL-safe ID. When set to 
`range_id`, the Plugin generates a sequential ID with specific parameters.      
           |
+| range_id      | object | False | |   | Configuration for generating a 
request ID using the `range_id` algorithm.  |
+| range_id.char_set      | string | False | 
"abcdefghijklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ0123456789" | minimum 
length 6 | Character set used for the `range_id` algorithm. |
+| range_id.length    | integer | False | 16             | >=6 | Length of the 
generated ID for the `range_id` algorithm. |
 
-## Enable Plugin
+## Examples
 
-The example below enables the Plugin on a specific Route:
+The examples below demonstrate how you can configure `request-id` in different 
scenarios.
 
 :::note
+
 You can fetch the `admin_key` from `config.yaml` and save to an environment 
variable with the following command:
 
 ```bash
@@ -61,54 +59,238 @@ admin_key=$(yq '.deployment.admin.admin_key[0].key' 
conf/config.yaml | sed 's/"/
 
 :::
 
+### Attach Request ID to Default Response Header
+
+The following example demonstrates how to configure `request-id` on a Route 
which attaches a generated request ID to the default `X-Request-Id` response 
header, if the header value is not passed in the request. When the 
`X-Request-Id` header is set in the request, the Plugin will take the value in 
the request header as the request ID.
+
+Create a Route with the `request-id` Plugin using its default configurations 
(explicitly defined):
+
 ```shell
-curl http://127.0.0.1:9180/apisix/admin/routes/5 \
--H "X-API-KEY: $admin_key" -X PUT -d '
-{
-    "uri": "/hello",
+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": {
-            "include_in_response": true
-        }
+      "request-id": {
+        "header_name": "X-Request-Id",
+        "include_in_response": true,
+        "algorithm": "uuid"
+      }
     },
     "upstream": {
-        "type": "roundrobin",
-        "nodes": {
-            "127.0.0.1:8080": 1
-        }
+      "type": "roundrobin",
+      "nodes": {
+        "httpbin.org:80": 1
+      }
     }
-}'
+  }'
+```
+
+Send a request to the Route:
+
+```shell
+curl -i "http://127.0.0.1:9080/anything";
+```
+
+You should receive an `HTTP/1.1 200 OK` response and see the response includes 
the `X-Request-Id` header with a generated ID:
+
+```text
+X-Request-Id: b9b2c0d4-d058-46fa-bafc-dd91a0ccf441
+```
+
+Send a request to the Route with a custom request ID in the header:
+
+```shell
+curl -i "http://127.0.0.1:9080/anything"; -H 'X-Request-Id: 
some-custom-request-id'
+```
+
+You should receive an `HTTP/1.1 200 OK` response and see the response includes 
the `X-Request-Id` header with the custom request ID:
+
+```text
+X-Request-Id: some-custom-request-id
 ```
 
-## Example usage
+### Attach Request ID to Custom Response Header
 
-Once you have configured the Plugin as shown above, APISIX will create a 
unique ID for each request you make:
+The following example demonstrates how to configure `request-id` on a Route 
which attaches a generated request ID to a specified header.
+
+Create a Route with the `request-id` Plugin to define a custom header that 
carries the request ID and include the request ID in the response header:
 
 ```shell
-curl -i http://127.0.0.1:9080/hello
+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": {
+        "header_name": "X-Req-Identifier",
+        "include_in_response": true
+      }
+    },
+    "upstream": {
+      "type": "roundrobin",
+      "nodes": {
+        "httpbin.org:80": 1
+      }
+    }
+  }'
 ```
 
+Send a request to the route:
+
 ```shell
-HTTP/1.1 200 OK
-X-Request-Id: fe32076a-d0a5-49a6-a361-6c244c1df956
+curl -i "http://127.0.0.1:9080/anything";
 ```
 
-## Delete Plugin
+You should receive an `HTTP/1.1 200 OK` response and see the response includes 
the `X-Req-Identifier` header with a generated ID:
+
+```text
+X-Req-Identifier: 1c42ff59-ee4c-4103-a980-8359f4135b21
+```
+
+### Hide Request ID in Response Header
+
+The following example demonstrates how to configure `request-id` on a Route 
which attaches a generated request ID to a specified header. The header 
containing the request ID should be forwarded to the Upstream service but not 
returned in the response header.
+
+Create a Route with the `request-id` Plugin to define a custom header that 
carries the request ID and not include the request ID in the response header:
+
+```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": {
+        "header_name": "X-Req-Identifier",
+        "include_in_response": false
+      }
+    },
+    "upstream": {
+      "type": "roundrobin",
+      "nodes": {
+        "httpbin.org:80": 1
+      }
+    }
+  }'
+```
 
-To remove the `request-id` Plugin, you can delete the corresponding JSON 
configuration from the Plugin configuration. APISIX will automatically reload 
and you do not have to restart for this to take effect.
+Send a request to the Route:
 
 ```shell
-curl http://127.0.0.1:9180/apisix/admin/routes/5 \
--H "X-API-KEY: $admin_key" -X PUT -d '
+curl -i "http://127.0.0.1:9080/anything";
+```
+
+You should receive an `HTTP/1.1 200 OK` response not and see 
`X-Req-Identifier` header among the response headers. In the response body, you 
should see:
+
+```json
 {
-    "uri": "/get",
+  "args": {},
+  "data": "",
+  "files": {},
+  "form": {},
+  "headers": {
+    "Accept": "*/*",
+    "Host": "127.0.0.1",
+    "User-Agent": "curl/8.6.0",
+    "X-Amzn-Trace-Id": "Root=1-6752748c-7d364f48564508db1e8c9ea8",
+    "X-Forwarded-Host": "127.0.0.1",
+    "X-Req-Identifier": "268092bc-15e1-4461-b277-bf7775f2856f"
+  },
+  ...
+}
+```
+
+This shows the request ID is forwarded to the Upstream service but not 
returned in the response header.
+
+### Use `nanoid` Algorithm
+
+The following example demonstrates how to configure `request-id` on a Route 
and use the `nanoid` algorithm to generate the request ID.
+
+Create a Route with the `request-id` Plugin as such:
+
+```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": "nanoid"
+      }
     },
     "upstream": {
-        "type": "roundrobin",
-        "nodes": {
-            "127.0.0.1:8080": 1
-        }
+      "type": "roundrobin",
+      "nodes": {
+        "httpbin.org:80": 1
+      }
+    }
+  }'
+```
+
+Send a request to the Route:
+
+```shell
+curl -i "http://127.0.0.1:9080/anything";
+```
+
+You should receive an `HTTP/1.1 200 OK` response and see the response includes 
the `X-Req-Identifier` header with an ID generated using the `nanoid` algorithm:
+
+```text
+X-Request-Id: kepgHWCH2ycQ6JknQKrX2
+```
+
+### Attach Request ID Globally and on a Route
+
+The following example demonstrates how to configure `request-id` as a global 
Plugin and on a Route to attach two IDs.
+
+Create a global rule for the `request-id` Plugin which adds request ID to a 
custom header:
+
+```shell
+curl -i "http://127.0.0.1:9180/apisix/admin/global_rules"; -X PUT -d '{
+  "id": "rule-for-request-id",
+  "plugins": {
+    "request-id": {
+      "header_name": "Global-Request-ID"
     }
+  }
 }'
 ```
+
+Create a Route with the `request-id` Plugin which adds request ID to a 
different custom header:
+
+```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": {
+        "header_name": "Route-Request-ID"
+      }
+    },
+    "upstream": {
+      "type": "roundrobin",
+      "nodes": {
+        "httpbin.org:80": 1
+      }
+    }
+  }'
+```
+
+Send a request to the Route:
+
+```shell
+curl -i "http://127.0.0.1:9080/anything";
+```
+
+You should receive an `HTTP/1.1 200 OK` response and see the response includes 
the following headers:
+
+```text
+Global-Request-ID: 2e9b99c1-08ed-4a74-b347-49c0891b07ad
+Route-Request-ID: d755666b-732c-4f0e-a30e-a7a71ace4e26
+```
diff --git a/docs/zh/latest/plugins/request-id.md 
b/docs/zh/latest/plugins/request-id.md
index 28bb996be..7747fc70a 100644
--- a/docs/zh/latest/plugins/request-id.md
+++ b/docs/zh/latest/plugins/request-id.md
@@ -4,7 +4,7 @@ keywords:
   - APISIX
   - API 网关
   - Request ID
-description: 本文介绍了 Apache APISIX request-id 插件的相关操作,你可以使用此插件为每个请求代理添加 unique 
ID 来追踪 API 请求。
+description: request-id 插件为通过 APISIX 代理的每个请求添加一个唯一的 ID,可用于跟踪 API 请求。
 ---
 
 <!--
@@ -28,27 +28,22 @@ description: 本文介绍了 Apache APISIX request-id 插件的相关操作,
 
 ## 描述
 
-`request-id` 插件通过 APISIX 为每一个请求代理添加 unique ID 用于追踪 API 请求。
-
-:::note 注意
-
-如果请求已经配置了 `header_name` 属性的请求头,该插件将不会为请求添加 unique ID。
-
-:::
+`request-id` 插件为每个通过 APISIX 代理的请求添加一个唯一 ID,可用于跟踪 API 请求。如果请求在 `header_name` 
对应的 header 中带有 ID,则插件将使用 header 值作为唯一 ID,而不会用自动生成的 ID 进行覆盖。
 
 ## 属性
 
 | 名称                | 类型    | 必选项   | 默认值         | 有效值 | 描述                   
        |
 | ------------------- | ------- | -------- | -------------- | ------ | 
------------------------------ |
-| header_name         | string  | 否 | "X-Request-Id" |                       | 
unique ID 的请求头的名称。         |
-| include_in_response | boolean | 否 | true          |                       | 
当设置为 `true` 时,将 unique ID 加入返回头。 |
-| algorithm           | string  | 否 | "uuid"         | ["uuid", "nanoid", 
"range_id"] | 指定的 unique ID 生成算法。 |
-| range_id.char_set      | string | 否 | 
"abcdefghijklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ0123456789| 字符串长度最小为 6 | 
range_id 算法的字符集 |
-| range_id.length    | integer | 否 | 16             | 最小值为 6 | range_id 算法的 id 
长度 |
+| header_name | string | 否 | "X-Request-Id" | | 携带请求唯一 ID 的标头的名称。请注意,如果请求在 
`header_name` 标头中携带 ID,则插件将使用标头值作为唯一 ID,并且不会用生成的 ID 覆盖它。|
+| include_in_response | 布尔值 | 否 | true | | 如果为 true,则将生成的请求 ID 
包含在响应标头中,其中标头的名称是 `header_name` 值。|
+| algorithm | string | 否 | "uuid" | ["uuid","nanoid","range_id"] | 用于生成唯一 ID 
的算法。设置为 `uuid` 时,插件会生成一个通用唯一标识符。设置为 `nanoid` 时,插件会生成一个紧凑的、URL 安全的 ID。设置为 
`range_id` 时,插件会生成具有特定参数的连续 ID。|
+| range_id | object | 否 | | |使用 `range_id` 算法生成请求 ID 的配置。|
+| range_id.char_set | string | 否 | 
"abcdefghijklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ0123456789" | 最小长度 6 | 用于 
`range_id` 算法的字符集。|
+| range_id.length | integer | 否 | 16 | >=6 | 用于 `range_id` 算法的生成的 ID 的长度。|
 
-## 启用插件
+## 示例
 
-以下示例展示了如何在指定路由上启用 `request-id` 插件:
+以下示例演示了如何在不同场景中配置“request-id”。
 
 :::note
 
@@ -60,58 +55,238 @@ admin_key=$(yq '.deployment.admin.admin_key[0].key' 
conf/config.yaml | sed 's/"/
 
 :::
 
+### 将请求 ID 附加到默认响应标头
+
+以下示例演示了如何在路由上配置 `request-id`,如果请求中未传递标头值,则将生成的请求 ID 附加到默认的 `X-Request-Id` 
响应标头。当在请求中设置 `X-Request-Id` 标头时,插件将把请求标头中的值作为请求 ID。
+
+使用其默认配置(明确定义)创建带有 `request-id` 插件的路由:
+
 ```shell
-curl http://127.0.0.1:9180/apisix/admin/routes/5 \
--H "X-API-KEY: $admin_key" -X PUT -d '
-{
-    "uri": "/hello",
+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": {
-            "include_in_response": true
-        }
+      "request-id": {
+        "header_name": "X-Request-Id",
+        "include_in_response": true,
+        "algorithm": "uuid"
+      }
     },
     "upstream": {
-        "type": "roundrobin",
-        "nodes": {
-            "127.0.0.1:8080": 1
-        }
+      "type": "roundrobin",
+      "nodes": {
+        "httpbin.org:80": 1
+      }
     }
-}'
+  }'
+```
+
+向路由发送请求:
+
+```shell
+curl -i "http://127.0.0.1:9080/anything";
 ```
 
-## 测试插件
+您应该会收到一个 `HTTP/1.1 200 OK` 响应,并且会看到响应包含 `X-Request-Id` 标头和生成的 ID:
 
-按上述配置启用插件后,APISIX 将为你的每个请求创建一个 unique ID。
+```text
+X-Request-Id: b9b2c0d4-d058-46fa-bafc-dd91a0ccf441
+```
 
-使用 `curl` 命令请求该路由:
+使用标头中的自定义请求 ID 向路由发送请求:
 
 ```shell
-curl -i http://127.0.0.1:9080/hello
+curl -i "http://127.0.0.1:9080/anything"; -H 'X-Request-Id: 
some-custom-request-id'
+```
+
+您应该会收到 `HTTP/1.1 200 OK` 响应,并看到响应包含带有自定义请求 ID 的 `X-Request-Id` 标头:
+
+```text
+X-Request-Id:some-custom-request-id
 ```
 
-返回的 HTTP 响应头中如果带有 `200` 状态码,且每次返回不同的 `X-Request-Id`,则表示插件生效:
+### 将请求 ID 附加到自定义响应标头
+
+以下示例演示如何在路由上配置 `request-id`,将生成的请求 ID 附加到指定的标头。
+
+使用 `request-id` 插件创建路由,以定义带有请求 ID 的自定义标头,并将请求 ID 包含在响应标头中:
 
 ```shell
-HTTP/1.1 200 OK
-X-Request-Id: fe32076a-d0a5-49a6-a361-6c244c1df956
+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": {
+        "header_name": "X-Req-Identifier",
+        "include_in_response": true
+      }
+    },
+    "upstream": {
+      "type": "roundrobin",
+      "nodes": {
+        "httpbin.org:80": 1
+      }
+    }
+  }'
+```
+
+向路由发送请求:
+
+```shell
+curl -i "http://127.0.0.1:9080/anything";
+```
+
+您应该收到一个 `HTTP/1.1 200 OK` 响应,并看到响应包含带有生成 ID 的 `X-Req-Identifier` 标头:
+
+```text
+X-Req-Identifier:1c42ff59-ee4c-4103-a980-8359f4135b21
 ```
 
-## 删除插件
+### 在响应标头中隐藏请求 ID
+
+以下示例演示如何在路由上配置 `request-id`,将生成的请求 ID 附加到指定的标头。包含请求 ID 的标头应转发到上游服务,但不会在响应标头中返回。
+
+使用 `request-id` 插件创建路由,以定义带有请求 ID 的自定义标头,而不在响应标头中包含请求 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": {
+        "header_name": "X-Req-Identifier",
+        "include_in_response": false
+      }
+    },
+    "upstream": {
+      "type": "roundrobin",
+      "nodes": {
+        "httpbin.org:80": 1
+      }
+    }
+  }'
+```
 
-当你需要删除该插件时,可以通过以下命令删除相应的 JSON 配置,APISIX 将会自动重新加载相关配置,无需重启服务:
+向路由发送请求:
 
 ```shell
-curl http://127.0.0.1:9180/apisix/admin/routes/5 \
--H "X-API-KEY: $admin_key" -X PUT -d '
+curl -i "http://127.0.0.1:9080/anything";
+```
+
+您应该收到 `HTTP/1.1 200 OK` 响应,并在响应标头中看到 `X-Req-Identifier` 标头。在响应主体中,您应该看到:
+
+```json
 {
-    "uri": "/get",
+  "args": {},
+  "data": "",
+  "files": {},
+  "form": {},
+  "headers": {
+    "Accept": "*/*",
+    "Host": "127.0.0.1",
+    "User-Agent": "curl/8.6.0",
+    "X-Amzn-Trace-Id": "Root=1-6752748c-7d364f48564508db1e8c9ea8",
+    "X-Forwarded-Host": "127.0.0.1",
+    "X-Req-Identifier": "268092bc-15e1-4461-b277-bf7775f2856f"
+  },
+  ...
+}
+```
+
+这表明请求 ID 已转发到上游服务,但未在响应标头中返回。
+
+### 使用 `nanoid` 算法
+
+以下示例演示如何在路由上配置 `request-id` 并使用 `nanoid` 算法生成请求 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": "nanoid"
+      }
     },
     "upstream": {
-        "type": "roundrobin",
-        "nodes": {
-            "127.0.0.1:8080": 1
-        }
+      "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 使用 `nanoid` 
算法生成:
+
+```text
+X-Request-Id: kepgHWCH2ycQ6JknQKrX2
+```
+
+### 全局和在路由上附加请求 ID
+
+以下示例演示如何将 `request-id` 配置为全局插件并在路由上附加两个 ID。
+
+为 `request-id` 插件创建全局规则,将请求 ID 添加到自定义标头:
+
+```shell
+curl -i "http://127.0.0.1:9180/apisix/admin/global_rules"; -X PUT -d '{
+  "id": "rule-for-request-id",
+  "plugins": {
+    "request-id": {
+      "header_name": "Global-Request-ID"
+    }
+  }
 }'
 ```
+
+使用 `request-id` 插件创建路由,将请求 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": {
+        "header_name": "Route-Request-ID"
+      }
+    },
+    "upstream": {
+      "type": "roundrobin",
+      "nodes": {
+        "httpbin.org:80": 1
+      }
+    }
+  }'
+```
+
+向路由发送请求:
+
+```shell
+curl -i "http://127.0.0.1:9080/anything";
+```
+
+您应该会收到 `HTTP/1.1 200 OK` 响应,并看到响应包含以下标头:
+
+```text
+Global-Request-ID:2e9b99c1-08ed-4a74-b347-49c0891b07ad
+Route-Request-ID:d755666b-732c-4f0e-a30e-a7a71ace4e26
+```

Reply via email to