Files
BiliDown/internal/util/response.go
T
yw1573 dd8eaef97d refactor: restructure project to standard Go layout
- Reorganize code into cmd/bilidown and internal/ packages
- Rename client/ to web/ for frontend source
- Remove systray dependency for headless web service
- Embed static files into binary using go:embed
- Update import paths to use internal/ prefix
- Update .gitignore with common patterns

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-02 17:21:49 +08:00

24 lines
454 B
Go

package util
import (
"encoding/json"
"net/http"
)
// 统一的 JSON 响应结构
type Res struct {
Success bool `json:"success"`
Message string `json:"message"`
Data any `json:"data"`
}
// 发送响应
func (r Res) Write(w http.ResponseWriter) {
bs, err := json.Marshal(r)
if err != nil {
w.Write([]byte(`{"success":false,"message":"系统错误","data":null}`))
}
w.Header().Set("Content-Type", "application/json")
w.Write(bs)
}