tokers commented on a change in pull request #1606:
URL: https://github.com/apache/apisix-dashboard/pull/1606#discussion_r595954707
##########
File path: api/internal/handler/handler.go
##########
@@ -104,3 +107,41 @@ func IDCompare(idOnPath string, idOnBody interface{})
error {
return nil
}
+
+func NameExistCheck(ctx context.Context, stg store.Interface, resource, name
string, excludeID interface{}) (interface{}, error) {
+ ret, err := stg.List(ctx, store.ListInput{
+ Predicate: func(obj interface{}) bool {
+ var objName string
+ var objID interface{}
+ switch resource {
+ case "route":
+ objID = obj.(*entity.Route).ID
+ objName = obj.(*entity.Route).Name
+ case "service":
+ objID = obj.(*entity.Service).ID
+ objName = obj.(*entity.Service).Name
+ case "upstream":
+ objID = obj.(*entity.Upstream).ID
+ objName = obj.(*entity.Upstream).Name
+ }
Review comment:
I think a default arm can be specified here:
```go
default:
panic("bad resource")
}
```
----------------------------------------------------------------
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:
[email protected]