This is an automated email from the ASF dual-hosted git repository.

rshah pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new 0c3a248f89 RFC3339 Fix for ProfileParameter (#7745)
0c3a248f89 is described below

commit 0c3a248f896cb9aa72b11245e9b61fbe644376f5
Author: Jagan Parthiban <[email protected]>
AuthorDate: Fri Aug 25 23:52:08 2023 +0530

    RFC3339 Fix for ProfileParameter (#7745)
    
    * CHANGELOG.md entry added
    
    * Removed Reflection usage
    
    * Removed Reflection usage
    
    * Fix conflicts
    
    * Fix conflicts
---
 .../profileparameter/profile_parameters.go                | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git 
a/traffic_ops/traffic_ops_golang/profileparameter/profile_parameters.go 
b/traffic_ops/traffic_ops_golang/profileparameter/profile_parameters.go
index 507f806e9a..601acbaf71 100644
--- a/traffic_ops/traffic_ops_golang/profileparameter/profile_parameters.go
+++ b/traffic_ops/traffic_ops_golang/profileparameter/profile_parameters.go
@@ -26,7 +26,6 @@ import (
        "fmt"
        "io"
        "net/http"
-       "reflect"
        "strconv"
        "time"
 
@@ -306,25 +305,15 @@ func CreateProfileParameter(w http.ResponseWriter, r 
*http.Request) {
                return
        }
 
-       // This code block decides if the request body is a slice of parameters 
or a single object.
+       // This code block decides if the request body is a slice of parameters 
or a single object and unmarshal it.
        var profileParams []tc.ProfileParameterCreationRequest
-       switch reflect.TypeOf(data).Kind() {
-       case reflect.Slice:
-               if err := json.Unmarshal(body, &profileParams); err != nil {
-                       api.HandleErr(w, r, tx, http.StatusBadRequest, 
errors.New("error unmarshalling slice"), nil)
-                       return
-               }
-       case reflect.Map:
-               // If it is a single object it is still converted to a slice 
for code simplicity.
+       if err := json.Unmarshal(body, &profileParams); err != nil {
                var profileParam tc.ProfileParameterCreationRequest
                if err := json.Unmarshal(body, &profileParam); err != nil {
                        api.HandleErr(w, r, tx, http.StatusBadRequest, 
errors.New("error unmarshalling single object"), nil)
                        return
                }
                profileParams = append(profileParams, profileParam)
-       default:
-               api.HandleErr(w, r, tx, http.StatusBadRequest, 
errors.New("invalid request format"), nil)
-               return
        }
 
        // Validate all objects of the every profile parameter from the request 
slice

Reply via email to