You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "lingsamuel (via GitHub)" <gi...@apache.org> on 2023/06/28 09:02:26 UTC
[GitHub] [apisix] lingsamuel commented on issue #9570: help request: how to get route_id
lingsamuel commented on issue #9570:
URL: https://github.com/apache/apisix/issues/9570#issuecomment-1611035935
Please give a minimal reproducible example. I can't repro this on my side.
Here is my reproduce way with APISIX 3.2
1. edit request-id plugin
```diff
function _M.header_filter(conf, ctx)
if not conf.include_in_response then
return
end
+ core.log.info("request-id got route_id: ", ngx.ctx.api_ctx.route_id)
local headers = ngx.resp.get_headers()
if not headers[conf.header_name] then
core.response.set_header(conf.header_name, ctx["request-id-" .. conf.header_name])
end
end
```
2. generate many routes

3. create a simple route with request-id plugin
```bash
curl http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '{
"uri": "/*",
"plugins": {
"request-id": {
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"baidu.com:80": 1
}
}
}'
```
4. query the route multiple times

--
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-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org