jiangfucheng commented on code in PR #8790:
URL: https://github.com/apache/apisix/pull/8790#discussion_r1101524856


##########
t/plugin/request-id.t:
##########
@@ -710,3 +710,144 @@ X-Request-ID: 123
 --- wait: 5
 --- response_body
 true
+
+
+
+=== TEST 21: check config with algorithm specified_character_id
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                 ngx.HTTP_PUT,
+                 [[{
+                        "plugins": {
+                            "request-id": {
+                                "algorithm": "specified_character_id",
+                                "specified_character_id_strs": "abcdefg",
+                                "specified_character_id_length" : 20
+                            }
+                        },
+                        "upstream": {
+                            "nodes": {
+                                "127.0.0.1:1982": 1
+                            },
+                            "type": "roundrobin"
+                        },
+                        "uri": "/opentracing"
+                }]]
+                )
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 22: add plugin with algorithm specified_character_id (default uuid)
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                 ngx.HTTP_PUT,
+                 [[{
+                        "plugins": {
+                            "request-id": {
+                                "algorithm": "specified_character_id"
+                            }
+                        },
+                        "upstream": {
+                            "nodes": {
+                                "127.0.0.1:1982": 1
+                            },
+                            "type": "roundrobin"
+                        },
+                        "uri": "/opentracing"
+                }]]
+                )
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 23: add plugin with algorithm specified_character_id (default uuid)
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local http = require "resty.http"
+            local v = {}
+            local ids = {}
+            local code, body = t('/apisix/admin/routes/1',
+                 ngx.HTTP_PUT,
+                 [[{
+                        "plugins": {
+                            "request-id": {
+                                "algorithm": "specified_character_id"
+                            }
+                        },
+                        "upstream": {

Review Comment:
   Fixed



##########
docs/en/latest/plugins/request-id.md:
##########
@@ -44,7 +44,9 @@ The Plugin will not add a unique ID if the request already 
has a header with the
 | ------------------- | ------- | -------- | -------------- | 
------------------------------- | 
---------------------------------------------------------------------- |
 | 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", 
"snowflake", "nanoid"] | Algorithm to use for generating the unique request ID. 
                |
+| algorithm           | string  | False    | "uuid"         | ["uuid", 
"snowflake", "nanoid", "specified_character_id"] | Algorithm to use for 
generating the unique request ID.                 |
+| specified_character_id_strs      | string | 否 | 
"abcdefghijklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ0123456789| The minimum 
string length is 6 | Character set for specified_character_id |

Review Comment:
   Fixed



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to