apache / apisix

The Cloud-Native API Gateway
https://apisix.apache.org/blog/
Apache License 2.0
14.43k stars 2.51k forks source link

help request: how to get route_id #9570

Closed RangoStack closed 1 year ago

RangoStack commented 1 year ago

Description

自定义插件怎么获取到请求的route_id呢? ngx.ctx.api_ctx.route_id这种方式获取到的route_id与实际请求的route_id不一致的情况。

Environment

Revolyssup commented 1 year ago

@RangoStack Can you elaborate further? In which plugin are you trying to access the route id?

moonming commented 1 year ago

@RangoStack Please use English in the public channel, thx Back to your question, can you provide reproduction steps? How do check the route id is not the ngx.ctx.api_ctx.route_id?

lingsamuel commented 1 year ago

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
    
    function _M.header_filter(conf, ctx)
    if not conf.include_in_response then
        return
    end
  1. generate many routes image

  2. create a simple route with request-id plugin

    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
        }
    }
    }'
  3. query the route multiple times image

github-actions[bot] commented 1 year ago

Due to lack of the reporter's response this issue has been labeled with "no response". It will be close in 3 days if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the dev@apisix.apache.org list. Thank you for your contributions.

github-actions[bot] commented 1 year ago

This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.