Files
Agent-System/internal/server/handlers_http.go
T
WeiCHEN 4c07716933 refactor(server): split handlers.go by domain
Keep slim handlers.go core; move chat/docgov/health/http/context
handlers into domain files ≤800 lines without behavior change.
2026-09-23 09:54:18 +08:00

19 lines
472 B
Go

package server
import (
"encoding/json"
"net/http"
"chat-agent-system/internal/httpx"
)
func writeJSONResponse(w http.ResponseWriter, status int, data any) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(status)
_ = json.NewEncoder(w).Encode(data)
}
func writeSafeError(w http.ResponseWriter, r *http.Request, status int, legacy string) {
httpx.Write(w, status, httpx.CodeFromStatus(status), legacy, httpx.RequestID(r), nil)
}