mirror of
https://gitee.com/iresty/apisix.git
synced 2024-12-15 01:11:58 +08:00
2.5 KiB
2.5 KiB
Summary
Name
request-id
plugin adds a unique ID (UUID) to each request proxied through APISIX. This plugin can be used to track an
API request. The plugin will not add a request id if the header_name
is already present in the request.
Attributes
Name | Requirement | Description |
---|---|---|
header_name | optional | Request ID header name (default: X-Request-Id) |
include_in_response | optional | Option to include the unique request ID in the response header (default: true) |
How To Enable
Create a route and enable the request-id plugin on the route:
curl http://127.0.0.1:9080/apisix/admin/routes/5 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/get",
"plugins": {
"request-id": {
"include_in_response": true
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"127.0.0.1:8080": 1
}
}
}
Test Plugin
$ curl -i http://127.0.0.1:9080/hello
HTTP/1.1 200 OK
Disable Plugin
Remove the corresponding json configuration in the plugin configuration to disable the request-id
.
APISIX plugins are hot-reloaded, therefore no need to restart APISIX.
curl http://127.0.0.1:9080/apisix/admin/routes/5 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/get",
"plugins": {
},
"upstream": {
"type": "roundrobin",
"nodes": {
"127.0.0.1:8080": 1
}
}
}