Skip to content

Commit

Permalink
Remove strconv and use APIINFO intParams utility.
Browse files Browse the repository at this point in the history
  • Loading branch information
jagan-parthiban committed Aug 24, 2023
1 parent 18b8306 commit 0bd3436
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions traffic_ops/traffic_ops_golang/parameter/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ func CreateParameter(w http.ResponseWriter, r *http.Request) {
}

func UpdateParameter(w http.ResponseWriter, r *http.Request) {
inf, userErr, sysErr, errCode := api.NewInfo(r, nil, nil)
inf, userErr, sysErr, errCode := api.NewInfo(r, nil, []string{"id"})
if userErr != nil || sysErr != nil {
api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr)
return
Expand All @@ -455,11 +455,8 @@ func UpdateParameter(w http.ResponseWriter, r *http.Request) {
}

requestedID := inf.Params["id"]
intRequestId := inf.IntParams["id"]

intRequestId, convErr := strconv.Atoi(requestedID)
if convErr != nil {
api.HandleErr(w, r, inf.Tx.Tx, http.StatusBadRequest, fmt.Errorf("parameter update error: %w, while converting from string to int", convErr), nil)
}
// check if the entity was already updated
userErr, sysErr, errCode = api.CheckIfUnModified(r.Header, inf.Tx, intRequestId, "parameter")
if userErr != nil || sysErr != nil {
Expand Down

0 comments on commit 0bd3436

Please sign in to comment.