log.Printf("[%s] APIV1ServicemgrServicesDelete", logPrefix)
}
-// APIV1ServicemgrServicesGet function
-func APIV1ServicemgrServicesGet(w http.ResponseWriter, r *http.Request) {
- log.Printf("[%s] APIV1ServicemgrServicesGet", logPrefix)
-}
-
// APIV1ServicemgrServicesPost function
func APIV1ServicemgrServicesPost(w http.ResponseWriter, r *http.Request) {
log.Printf("[%s] APIV1ServicemgrServicesPost", logPrefix)
id, err := strconv.ParseUint(serviceID, 10, 64)
if len(serviceID) == 0 || err != nil {
- w.Header().Set("Content-Type", "application/json; charset=UTF-8")
- w.WriteHeader(http.StatusBadRequest)
+ writeJSONResponse(w, nil, http.StatusBadRequest)
} else {
servicemgr.DataPathHandler(w, r, id)
-
- w.Header().Set("Content-Type", "application/json; charset=UTF-8")
- w.WriteHeader(http.StatusOK)
+ writeJSONResponse(w, nil, http.StatusOK)
}
}
-// APIV1ServicemgrServicesServiceIDGet function
-func APIV1ServicemgrServicesServiceIDGet(w http.ResponseWriter, r *http.Request) {
- log.Printf("[%s] APIV1ServicemgrServicesServiceIDGet", logPrefix)
-}
-
// APIV1ServicemgrServicesServiceIDPost function
func APIV1ServicemgrServicesServiceIDPost(w http.ResponseWriter, r *http.Request) {
log.Printf("[%s] APIV1ServicemgrServicesServiceIDPost", logPrefix)
ret, err := servicemgr.ServiceList()
if err != nil {
- w.Header().Set("Content-Type", "application/json; charset=UTF-8")
writeJSONResponse(w, nil, http.StatusBadRequest)
- return
}
json, err := json.Marshal(ret)
if err == nil {
- w.Header().Set("Content-Type", "application/json; charset=UTF-8")
writeJSONResponse(w, json, http.StatusOK)
} else {
- w.Header().Set("Content-Type", "application/json; charset=UTF-8")
writeJSONResponse(w, nil, http.StatusBadRequest)
}
}
-// APIV1ServicemgrServicesGetByAppName function
-func APIV1ServicemgrServicesGetByAppName(w http.ResponseWriter, r *http.Request) {
- log.Printf("[%s] APIV1ServicemgrServicesGetByAppName", logPrefix)
+// APIV1ServicemgrServicesAppnameGet function
+func APIV1ServicemgrServicesAppnameGet(w http.ResponseWriter, r *http.Request) {
+ log.Printf("[%s] APIV1ServicemgrServicesAppnameGet", logPrefix)
vars := mux.Vars(r)
appName := vars["appname"]
ret, err := servicemgr.FindServiceByName(appName)
if err != nil {
- w.Header().Set("Content-Type", "application/json; charset=UTF-8")
writeJSONResponse(w, nil, http.StatusBadRequest)
- return
}
json, err := json.Marshal(ret)
if err == nil {
- w.Header().Set("Content-Type", "application/json; charset=UTF-8")
writeJSONResponse(w, json, http.StatusOK)
} else {
- w.Header().Set("Content-Type", "application/json; charset=UTF-8")
writeJSONResponse(w, nil, http.StatusBadRequest)
}
}
-// APIV1ServicemgrServicesGetByServiceID function
-func APIV1ServicemgrServicesGetByServiceID(w http.ResponseWriter, r *http.Request) {
- log.Printf("[%s] APIV1ServicemgrServicesGetByServiceID", logPrefix)
+// APIV1ServicemgrServicesServiceIDGet function
+func APIV1ServicemgrServicesServiceIDGet(w http.ResponseWriter, r *http.Request) {
+ log.Printf("[%s] APIV1ServicemgrServicesServiceIDGet", logPrefix)
vars := mux.Vars(r)
serviceID := vars["serviceid"]
id, err := strconv.ParseUint(serviceID, 10, 64)
if err != nil {
- w.Header().Set("Content-Type", "application/json; charset=UTF-8")
writeJSONResponse(w, nil, http.StatusBadRequest)
- return
}
ret, err := servicemgr.FindServiceByID(id)
if err != nil {
- w.Header().Set("Content-Type", "application/json; charset=UTF-8")
writeJSONResponse(w, nil, http.StatusBadRequest)
- return
}
json, err := json.Marshal(ret)
if err == nil {
- w.Header().Set("Content-Type", "application/json; charset=UTF-8")
writeJSONResponse(w, json, http.StatusOK)
} else {
- w.Header().Set("Content-Type", "application/json; charset=UTF-8")
writeJSONResponse(w, nil, http.StatusBadRequest)
}
}
},
Route{
+ "APIV1ServicemgrServicesAppnameGet",
+ strings.ToUpper("Get"),
+ "/api/v1/servicemgr/services/{appname}",
+ APIV1ServicemgrServicesAppnameGet,
+ },
+
+ Route{
"APIV1ServicemgrServicesDelete",
strings.ToUpper("Delete"),
"/api/v1/servicemgr/services",
"/api/v1/servicemgr/services/{serviceid}",
APIV1ServicemgrServicesServiceIDPost,
},
-
- Route{
- "APIV1ServicemgrServicesGet",
- strings.ToUpper("Get"),
- "/api/v1/servicemgr/services",
- APIV1ServicemgrServicesGet,
- },
-
- Route{
- "APIV1ServicemgrServicesGetByAppName",
- strings.ToUpper("Get"),
- "/api/v1/servicemgr/services/{appname}",
- APIV1ServicemgrServicesGetByAppName,
- },
-
- Route{
- "APIV1ServicemgrServicesGetByServiceID",
- strings.ToUpper("Get"),
- "/api/v1/servicemgr/services/{serviceid}",
- APIV1ServicemgrServicesGetByServiceID,
- },
}