rawlinp commented on a change in pull request #4942:
URL: https://github.com/apache/trafficcontrol/pull/4942#discussion_r505666697
##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -789,6 +789,18 @@ func updateV30(w http.ResponseWriter, r *http.Request, inf
*api.APIInfo, ds *tc.
deepCachingType = ds.DeepCachingType.String() // necessary,
because DeepCachingType's default needs to insert the string, not "", and Query
doesn't call .String().
}
+ existingLastUpdated, found, err := api.GetLastUpdated(inf.Tx, *ds.ID,
"deliveryservice")
+ if err == nil && found == false {
+ return nil, http.StatusNotFound, errors.New("no deliveryservice
found with this id"), nil
+ }
+ if err != nil {
+ return nil, http.StatusInternalServerError, nil, err
+ }
+
+ if !api.IsUnmodified(r.Header, *existingLastUpdated) {
+ return nil, http.StatusPreconditionFailed, errors.New("resource
was modified"), nil
+ }
+
Review comment:
It looks like these lines are duplicated across multiple endpoints --can
we refactor them into a shared function?
----------------------------------------------------------------
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]