修复(#105): 消除 goctl 重新生成漂移

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
2026-05-27 23:50:16 -07:00
parent 27986044a1
commit b6d0c89aa1
43 changed files with 2986 additions and 1498 deletions
+27
View File
@@ -0,0 +1,27 @@
package httpx
import (
"context"
"encoding/json"
"net/http"
)
func Parse(r *http.Request, v any) error {
if r.Body == nil {
return nil
}
decoder := json.NewDecoder(r.Body)
if err := decoder.Decode(v); err != nil {
return err
}
return nil
}
func ErrorCtx(_ context.Context, w http.ResponseWriter, err error) {
http.Error(w, err.Error(), http.StatusBadRequest)
}
func OkJsonCtx(_ context.Context, w http.ResponseWriter, v any) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
_ = json.NewEncoder(w).Encode(v)
}