Commit 2d193317 authored by Muhammad Umair Khan's avatar Muhammad Umair Khan
Browse files

Fix issue #13: Location header for service and subscription POST in CAPIF management

parent 4f5f5ea5
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ const globalMepName = "global"
const SER_AVAILABILITY_NOTIF_SUB_TYPE = "SerAvailabilityNotificationSubscription"
const SER_AVAILABILITY_NOTIF_TYPE = "SerAvailabilityNotification"
const APP_STATE_READY = "READY"
const capifEventsBasePath = "/capif-events/v1/"

// const logModuleAppEnablement = "meep-app-enablement"
const serviceName = "App Enablement Service"
@@ -416,8 +417,11 @@ func appServicesPOST(w http.ResponseWriter, r *http.Request) {
		return
	}

	// Set Location Header
	updatedBasePath := strings.Replace(basePath, "mec_service_mgmt/v1", "published-apis/v1", 1)

	// Send response
	w.Header().Set("Location", hostUrl.String()+basePath+"applications/"+appId+"/services/"+sInfo.SerInstanceId)
	w.Header().Set("Location", hostUrl.String()+updatedBasePath+appId+"/service-apis/"+dsInfo.ApiId)
	w.WriteHeader(http.StatusCreated)
	fmt.Fprint(w, convertServiceInfoToJson_1(dsInfo))
}
@@ -1210,7 +1214,11 @@ func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) {
		errHandlerProblemDetails(w, "Failed to create subscription", http.StatusInternalServerError)
		return
	}
	HrefUrl = hostUrl.String() + basePath + "applications/" + appId + "/subscriptions/" + subId

	// Set Location Header
	updatedBasePath := strings.Replace(basePath, "mec_service_mgmt/v1", "capif-events/v1", 1)
	HrefUrl := hostUrl.String() + updatedBasePath + appId + "/subscriptions/" + subId

	// Send response
	w.Header().Set("Location", HrefUrl)
	w.WriteHeader(http.StatusCreated)