liuxiran commented on issue #2479:
URL: https://github.com/apache/apisix/issues/2479#issuecomment-712813560


   > you can take the `name` as `id`, for example:
   > `http://127.0.0.1:9080/apisix/admin/routes/test1`
   
   test result:
   
   1. create a route id: user1,name:test1
   
   ```shell
   [**** compose]$ curl http://127.0.0.1:9080/apisix/admin/routes/user1 -H 
'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d 
'{"name":"test1","uri":"/index.html","hosts":["foo.com","*.bar.com"],"remote_addrs":["127.0.0.0/8"],"methods":["PUT","GET"],"upstream":{"type":"roundrobin","nodes":{"39.97.63.215:80":1}}}'
   HTTP/1.1 201 Created
   Server: openresty
   Date: Tue, 20 Oct 2020 12:01:43 GMT
   Content-Type: application/json
   Transfer-Encoding: chunked
   Connection: keep-alive
   Access-Control-Allow-Origin: *
   Access-Control-Allow-Credentials: true
   Access-Control-Expose-Headers: *
   Access-Control-Max-Age: 3600
   
   
{"node":{"key":"\/apisix\/routes\/1000","value":{"priority":0,"methods":["PUT","GET"],"uri":"\/index.html","remote_addrs":["127.0.0.0\/8"],"hosts":["foo.com","*.bar.com"],"name":"test1","id":"1000","upstream":{"pass_host":"pass","hash_on":"vars","nodes":{"39.97.63.215:80":1},"type":"roundrobin"}}},"header":{"raft_term":"5","cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"102"},"action":"set"}
   ```
   
   2. create route id: user1, name test2
   
   ```shell
   [**** compose]$ curl http://127.0.0.1:9080/apisix/admin/routes/user1 -H 
'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d 
'{"name":"test2","uri":"/index.html","hosts":["foo.com","*.bar.com"],"remote_addrs":["127.0.0.0/8"],"methods":["PUT","GET"],"upstream":{"type":"roundrobin","nodes":{"39.97.63.215:80":1}}}'
   HTTP/1.1 200 OK
   Server: openresty
   Date: Tue, 20 Oct 2020 12:11:10 GMT
   Content-Type: application/json
   Transfer-Encoding: chunked
   Connection: keep-alive
   Access-Control-Allow-Origin: *
   Access-Control-Allow-Credentials: true
   Access-Control-Expose-Headers: *
   Access-Control-Max-Age: 3600
   
   
{"node":{"key":"\/apisix\/routes\/user1","value":{"priority":0,"methods":["PUT","GET"],"uri":"\/index.html","remote_addrs":["127.0.0.0\/8"],"hosts":["foo.com","*.bar.com"],"name":"test2","id":"user1","upstream":{"pass_host":"pass","hash_on":"vars","nodes":{"39.97.63.215:80":1},"type":"roundrobin"}}},"header":{"raft_term":"5","cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"105"},"action":"set"}
   [**** compose]$ curl http://127.0.0.1:9080/apisix/admin/routes/user1 -H 
'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1'
   
{"node":{"value":{"priority":0,"methods":["PUT","GET"],"uri":"\/index.html","remote_addrs":["127.0.0.0\/8"],"hosts":["foo.com","*.bar.com"],"name":"test2","upstream":{"type":"roundrobin","nodes":{"39.97.63.215:80":1},"hash_on":"vars","pass_host":"pass"},"id":"user1"},"modifiedIndex":105,"key":"\/apisix\/routes\/user1","createdIndex":103},"count":"1","action":"get","header":{"raft_term":"5","cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"105"}}
   ```
   
   **Actually two duplicate id route create successfully, and the second one‘s 
data coverd the former**
   so there should be a  unique key whether it's id or name


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to