From 29ae8b5de86d527689d60f0fdf44e9076ca5aad0 Mon Sep 17 00:00:00 2001 From: sky5454 Date: Tue, 31 Mar 2026 05:33:34 +0800 Subject: [PATCH] fix(ci): fix ci lint fmt err --- web/backend/api/update.go | 60 +++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/web/backend/api/update.go b/web/backend/api/update.go index 759f1a3a2..2ba862631 100644 --- a/web/backend/api/update.go +++ b/web/backend/api/update.go @@ -1,52 +1,52 @@ package api import ( - "encoding/json" - "net/http" + "encoding/json" + "net/http" - "github.com/sipeed/picoclaw/pkg/updater" + "github.com/sipeed/picoclaw/pkg/updater" ) // registerUpdateRoutes registers the self-update endpoint. func (h *Handler) registerUpdateRoutes(mux *http.ServeMux) { - mux.HandleFunc("/api/update", h.handleUpdate) + mux.HandleFunc("/api/update", h.handleUpdate) } type updateRequest struct { - URL string `json:"url,omitempty"` - Binary string `json:"binary,omitempty"` + URL string `json:"url,omitempty"` + Binary string `json:"binary,omitempty"` } type updateResponse struct { - Status string `json:"status"` - Message string `json:"message,omitempty"` + Status string `json:"status"` + Message string `json:"message,omitempty"` } func (h *Handler) handleUpdate(w http.ResponseWriter, r *http.Request) { - if r.Method != http.MethodPost { - w.WriteHeader(http.StatusMethodNotAllowed) - _ = json.NewEncoder(w).Encode(updateResponse{Status: "error", Message: "method not allowed"}) - return - } + if r.Method != http.MethodPost { + w.WriteHeader(http.StatusMethodNotAllowed) + _ = json.NewEncoder(w).Encode(updateResponse{Status: "error", Message: "method not allowed"}) + return + } - dec := json.NewDecoder(http.MaxBytesReader(w, r.Body, 1<<20)) - var req updateRequest - if err := dec.Decode(&req); err != nil { - w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(updateResponse{Status: "error", Message: "invalid request body"}) - return - } + dec := json.NewDecoder(http.MaxBytesReader(w, r.Body, 1<<20)) + var req updateRequest + if err := dec.Decode(&req); err != nil { + w.WriteHeader(http.StatusBadRequest) + _ = json.NewEncoder(w).Encode(updateResponse{Status: "error", Message: "invalid request body"}) + return + } - binary := req.Binary - if binary == "" { - binary = "picoclaw-launcher" - } + binary := req.Binary + if binary == "" { + binary = "picoclaw-launcher" + } - if err := updater.UpdateSelfFromRelease(req.URL, "", "", binary); err != nil { - w.WriteHeader(http.StatusInternalServerError) - _ = json.NewEncoder(w).Encode(updateResponse{Status: "error", Message: err.Error()}) - return - } + if err := updater.UpdateSelfFromRelease(req.URL, "", "", binary); err != nil { + w.WriteHeader(http.StatusInternalServerError) + _ = json.NewEncoder(w).Encode(updateResponse{Status: "error", Message: err.Error()}) + return + } - _ = json.NewEncoder(w).Encode(updateResponse{Status: "ok", Message: "update applied; restart to use new version"}) + _ = json.NewEncoder(w).Encode(updateResponse{Status: "ok", Message: "update applied; restart to use new version"}) }