RedemptionC commented on issue #2011:
URL: 
https://github.com/apache/apisix-dashboard/issues/2011#issuecomment-890367707


   > hi @RedemptionC
   > 
   > The relevant data needs to be written before there is a cache.
   > 
   > In your example, you should create a consumer first.
   
   thanks 
   And when I study the code,I found that:
   in consumer.go,there are Get,List,Set handler,and it also apply route for 
them,i.e.,when user use the API,these method should be called
   ```go
        r.GET("/apisix/admin/consumers", wgin.Wraps(h.List,
                wrapper.InputType(reflect.TypeOf(ListInput{}))))
   
        r.PUT("/apisix/admin/consumers", wgin.Wraps(h.Set,
                wrapper.InputType(reflect.TypeOf(SetInput{}))))
   ```
   but I tried:
   query all consumers
   ```
   curl localhost:9000/apisix/admin/consumers -H "Authorization: $(curl -s  
localhost:9000/apisix/admin/user/login -X POST -d 
'{"username":"admin","password":"admin"}'  | jq -r '.data | .token')" | jq
   
   ```
   create new consumer
   ```
   curl "http://127.0.0.1:9080/apisix/admin/consumers"; -H "X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1" -X PUT -d '
   {                          
     "username": "apisix",
     "plugins": {
       "key-auth": {
         "key": "key-of-john"
       }
     }
   }'
   
   ```
   and something else,only the consumer.List method is called
   ```
   consumer.List is called
   in list(Store.go)
   cache: key(andy):val(&{andy  map[key-auth:map[key:key-of-john]] map[] 
%!s(int64=1627739045) %!s(int64=1627744978)})
   cache: key(john):val(&{john  map[key-auth:map[key:key-of-john]] map[] 
%!s(int64=1627731085) %!s(int64=1627738858)})
   cache: key(red):val(&{red  map[key-auth:map[key:key-of-john]] map[] 
%!s(int64=1627738877) %!s(int64=1627738933)})
   cache: key(dashboard):val(&{dashboard  map[key-auth:map[key:key-of-john]] 
map[] %!s(int64=1627746151) %!s(int64=1627746151)})
   cache: key(apisix):val(&{apisix  map[key-auth:map[key:key-of-john]] map[] 
%!s(int64=1627746172) %!s(int64=1627746172)})
   
   ```
   while other api also takes effect,i.e.,it did create a new consumer
   1. how should I make sense of it? why consumer.Set is not called?
   2. did I use the admin API the right way? i.e.,when I create a consumer , I 
need to have a X-API-KEY in my header? is it OK to use the key in the offcial 
doc's example,or should I use my own key?Do I need to login in to get it?
   3. also,I don't quite understand how dashboard use etcd,I'm trying to figure 
out it,and any forms of help will be appreciated


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