Loading go-apps/meep-loc-serv/server/loc-serv.go +116 −124 Original line number Diff line number Diff line Loading @@ -3687,8 +3687,8 @@ func zoneSubGET(w http.ResponseWriter, r *http.Request) { } func zoneSubPOST(w http.ResponseWriter, r *http.Request) { // Decode the request body into a slice of maps var requestBody []map[string]interface{} var requestBody map[string]interface{} decoder := json.NewDecoder(r.Body) if err := decoder.Decode(&requestBody); err != nil { Loading @@ -3699,13 +3699,12 @@ func zoneSubPOST(w http.ResponseWriter, r *http.Request) { hasZoneSubscription := false hasStatusSubscription := false for _, body := range requestBody { if _, ok := body["zoneLocationEventSubscription"]; ok { if _, ok := requestBody["zoneLocationEventSubscription"]; ok { hasZoneSubscription = true } else if _, ok := body["zoneStatusSubscription"]; ok { } else if _, ok := requestBody["zoneStatusSubscription"]; ok { hasStatusSubscription = true } } // Check if both types of subscriptions are present if hasZoneSubscription && hasStatusSubscription { errHandlerProblemDetails(w, "Please send only one type of subscription at a time", http.StatusBadRequest) Loading @@ -3720,9 +3719,9 @@ func zoneSubPOST(w http.ResponseWriter, r *http.Request) { return } } func handleZoneStatusSubscription(w http.ResponseWriter, requestBody []map[string]interface{}) { for _, body := range requestBody { if statusSubscription, ok := body["zoneStatusSubscription"]; ok { func handleZoneStatusSubscription(w http.ResponseWriter, requestBody map[string]interface{}) { if statusSubscription, ok := requestBody["zoneStatusSubscription"]; ok { // Convert the Status subscription to a map statusSubscriptionMap := statusSubscription.(map[string]interface{}) // Decode the Zone subscription map into a struct Loading Loading @@ -3783,14 +3782,10 @@ func handleZoneStatusSubscription(w http.ResponseWriter, requestBody []map[strin return } } // If no event-based subscription found in the request body errHandlerProblemDetails(w, "No valid event-based subscription found in the request body", http.StatusBadRequest) } func handleZoneLocationEventSubscription(w http.ResponseWriter, requestBody []map[string]interface{}) { // Iterate over each item in the request body for _, body := range requestBody { if zoneLocationEventSubscription, ok := body["zoneLocationEventSubscription"]; ok { func handleZoneLocationEventSubscription(w http.ResponseWriter, requestBody map[string]interface{}) { if zoneLocationEventSubscription, ok := requestBody["zoneLocationEventSubscription"]; ok { zoneLocationEventSubscriptionMap := zoneLocationEventSubscription.(map[string]interface{}) // Decode the zone subscription map into a struct var zonalSub ZoneLocationEventSubscription Loading Loading @@ -3844,9 +3839,6 @@ func handleZoneLocationEventSubscription(w http.ResponseWriter, requestBody []ma return } } // If no zone-based subscription found in the request body errHandlerProblemDetails(w, "No valid zone Event-based subscription found in the request body", http.StatusBadRequest) } func populateZonalTrafficList(data []byte, zoneId string, subscriptions *[]Subscription) error { var zoneInfo ZoneLocationEventSubscription Loading Loading
go-apps/meep-loc-serv/server/loc-serv.go +116 −124 Original line number Diff line number Diff line Loading @@ -3687,8 +3687,8 @@ func zoneSubGET(w http.ResponseWriter, r *http.Request) { } func zoneSubPOST(w http.ResponseWriter, r *http.Request) { // Decode the request body into a slice of maps var requestBody []map[string]interface{} var requestBody map[string]interface{} decoder := json.NewDecoder(r.Body) if err := decoder.Decode(&requestBody); err != nil { Loading @@ -3699,13 +3699,12 @@ func zoneSubPOST(w http.ResponseWriter, r *http.Request) { hasZoneSubscription := false hasStatusSubscription := false for _, body := range requestBody { if _, ok := body["zoneLocationEventSubscription"]; ok { if _, ok := requestBody["zoneLocationEventSubscription"]; ok { hasZoneSubscription = true } else if _, ok := body["zoneStatusSubscription"]; ok { } else if _, ok := requestBody["zoneStatusSubscription"]; ok { hasStatusSubscription = true } } // Check if both types of subscriptions are present if hasZoneSubscription && hasStatusSubscription { errHandlerProblemDetails(w, "Please send only one type of subscription at a time", http.StatusBadRequest) Loading @@ -3720,9 +3719,9 @@ func zoneSubPOST(w http.ResponseWriter, r *http.Request) { return } } func handleZoneStatusSubscription(w http.ResponseWriter, requestBody []map[string]interface{}) { for _, body := range requestBody { if statusSubscription, ok := body["zoneStatusSubscription"]; ok { func handleZoneStatusSubscription(w http.ResponseWriter, requestBody map[string]interface{}) { if statusSubscription, ok := requestBody["zoneStatusSubscription"]; ok { // Convert the Status subscription to a map statusSubscriptionMap := statusSubscription.(map[string]interface{}) // Decode the Zone subscription map into a struct Loading Loading @@ -3783,14 +3782,10 @@ func handleZoneStatusSubscription(w http.ResponseWriter, requestBody []map[strin return } } // If no event-based subscription found in the request body errHandlerProblemDetails(w, "No valid event-based subscription found in the request body", http.StatusBadRequest) } func handleZoneLocationEventSubscription(w http.ResponseWriter, requestBody []map[string]interface{}) { // Iterate over each item in the request body for _, body := range requestBody { if zoneLocationEventSubscription, ok := body["zoneLocationEventSubscription"]; ok { func handleZoneLocationEventSubscription(w http.ResponseWriter, requestBody map[string]interface{}) { if zoneLocationEventSubscription, ok := requestBody["zoneLocationEventSubscription"]; ok { zoneLocationEventSubscriptionMap := zoneLocationEventSubscription.(map[string]interface{}) // Decode the zone subscription map into a struct var zonalSub ZoneLocationEventSubscription Loading Loading @@ -3844,9 +3839,6 @@ func handleZoneLocationEventSubscription(w http.ResponseWriter, requestBody []ma return } } // If no zone-based subscription found in the request body errHandlerProblemDetails(w, "No valid zone Event-based subscription found in the request body", http.StatusBadRequest) } func populateZonalTrafficList(data []byte, zoneId string, subscriptions *[]Subscription) error { var zoneInfo ZoneLocationEventSubscription Loading