refactor(api): simplify instance management endpoints
- Change delete endpoint to use request body instead of path parameter - Modify endpoint now takes field as path parameter and instance name in body - Update README to reflect API changes - Remove unused description field from software info - Fix error message in auth token lookup
This commit is contained in:
@@ -224,7 +224,7 @@ func CreateInstanceHandler(w http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
}
|
||||
|
||||
func DeleteInstanceHandler(w http.ResponseWriter, r *http.Request, instanceName string) {
|
||||
func DeleteInstanceHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
SendErrorResponse(w, http.StatusMethodNotAllowed, "Invalid request method")
|
||||
return
|
||||
@@ -238,6 +238,19 @@ func DeleteInstanceHandler(w http.ResponseWriter, r *http.Request, instanceName
|
||||
}
|
||||
defer r.Body.Close()
|
||||
|
||||
var reqMap map[string]interface{}
|
||||
if err := json.Unmarshal(body, &reqMap); err != nil {
|
||||
postLog.Error(fmt.Sprintf("[DeleteInstanceHandler] Failed to unmarshal request body: %v", err))
|
||||
SendErrorResponse(w, http.StatusBadRequest, "Invalid request format")
|
||||
return
|
||||
}
|
||||
|
||||
instanceName := getStringFromMap(reqMap, "instanceName")
|
||||
if instanceName == "" {
|
||||
SendErrorResponse(w, http.StatusBadRequest, "instanceName is required")
|
||||
return
|
||||
}
|
||||
|
||||
userID, _, err := ValidateRequestWithBody(w, r, body)
|
||||
if err != nil {
|
||||
postLog.Error(fmt.Sprintf("[DeleteInstanceHandler] Failed to validate request body: %v", err))
|
||||
@@ -304,7 +317,7 @@ func DeleteInstanceHandler(w http.ResponseWriter, r *http.Request, instanceName
|
||||
})
|
||||
}
|
||||
|
||||
func ModifyInstanceHandler(w http.ResponseWriter, r *http.Request, instanceName string) {
|
||||
func ModifyInstanceHandler(w http.ResponseWriter, r *http.Request, field string) {
|
||||
if r.Method != http.MethodPost {
|
||||
postLog.Error(fmt.Sprintf("[ModifyInstanceHandler] Invalid request method: %s", r.Method))
|
||||
SendErrorResponse(w, http.StatusMethodNotAllowed, "Invalid request method")
|
||||
@@ -326,6 +339,12 @@ func ModifyInstanceHandler(w http.ResponseWriter, r *http.Request, instanceName
|
||||
return
|
||||
}
|
||||
|
||||
instanceName := getStringFromMap(reqMap, "instanceName")
|
||||
if instanceName == "" {
|
||||
SendErrorResponse(w, http.StatusBadRequest, "instanceName is required")
|
||||
return
|
||||
}
|
||||
|
||||
userID, _, err := ValidateRequestWithBody(w, r, body)
|
||||
if err != nil {
|
||||
postLog.Error(fmt.Sprintf("[ModifyInstanceHandler] Failed to validate request body: %v", err))
|
||||
|
||||
Reference in New Issue
Block a user