feat: delete firmware
This commit is contained in:
@@ -151,6 +151,7 @@ func (hs *HTTPServer) setupRoutes() {
|
||||
api.HandleFunc("/registry/firmware", hs.uploadRegistryFirmware).Methods("POST", "OPTIONS")
|
||||
api.HandleFunc("/registry/firmware/{name}/{version}", hs.downloadRegistryFirmware).Methods("GET")
|
||||
api.HandleFunc("/registry/firmware/{name}/{version}", hs.updateRegistryFirmware).Methods("PUT", "OPTIONS")
|
||||
api.HandleFunc("/registry/firmware/{name}/{version}", hs.deleteRegistryFirmware).Methods("DELETE", "OPTIONS")
|
||||
|
||||
// Test endpoints
|
||||
api.HandleFunc("/test/websocket", hs.testWebSocket).Methods("POST", "OPTIONS")
|
||||
@@ -1234,3 +1235,25 @@ func (hs *HTTPServer) updateRegistryFirmware(w http.ResponseWriter, r *http.Requ
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(result)
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) deleteRegistryFirmware(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
name := vars["name"]
|
||||
version := vars["version"]
|
||||
|
||||
if name == "" || version == "" {
|
||||
http.Error(w, `{"error": "Missing parameters", "message": "Name and version are required"}`, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete firmware from registry
|
||||
result, err := hs.registryClient.DeleteFirmware(name, version)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to delete firmware from registry")
|
||||
http.Error(w, fmt.Sprintf(`{"error": "Delete failed", "message": "%s"}`, err.Error()), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(result)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user