Keep slim handlers.go core; move chat/docgov/health/http/context handlers into domain files ≤800 lines without behavior change.
19 lines
472 B
Go
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)
|
|
}
|