You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2020/02/07 21:36:45 UTC

[GitHub] [trafficcontrol] zrhoffman commented on a change in pull request #4357: Deprecate /regions/name/{{name}}

zrhoffman commented on a change in pull request #4357: Deprecate /regions/name/{{name}}
URL: https://github.com/apache/trafficcontrol/pull/4357#discussion_r376619012
 
 

 ##########
 File path: traffic_ops/traffic_ops_golang/api/shared_handlers.go
 ##########
 @@ -298,23 +298,36 @@ func DeleteHandler(deleter Deleter) http.HandlerFunc {
 		obj := reflect.New(objectType).Interface().(Deleter)
 		obj.SetInfo(inf)
 
-		keyFields := obj.GetKeyFieldsInfo() // expecting a slice of the key fields info which is a struct with the field name and a function to convert a string into a interface{} of the right type. in most that will be [{Field:"id",Func: func(s string)(interface{},error){return strconv.Atoi(s)}}]
-		keys := make(map[string]interface{})
-		for _, kf := range keyFields {
-			paramKey := inf.Params[kf.Field]
-			if paramKey == "" {
-				HandleErr(w, r, inf.Tx.Tx, http.StatusBadRequest, errors.New("missing key: "+kf.Field), nil)
-				return
+		deleteKeyOptionExists := false
+		if d, ok := obj.(HasDeleteKeyOptions); ok {
+			options := d.DeleteKeyOptions()
+			for key, _ := range options {
+				if inf.Params[key] != "" {
+					deleteKeyOptionExists = true
+					break
+				}
 			}
 
 Review comment:
   Having that error makes sense to me.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services