Documentation
¶
Overview ¶
Package response provides utilities for writing HTTP responses in the Zero server. It includes functions for writing JSON responses, error responses, and setting response headers.
Index ¶
- func InternalServerError(w http.ResponseWriter, err error)
- func SetHeader(w http.ResponseWriter, key, value string)
- func Write(w http.ResponseWriter, contentType string, statusCode int, data []byte)
- func WriteError(w http.ResponseWriter, statusCode int, err error)
- func WriteErrorMsg(w http.ResponseWriter, statusCode int, message string)
- func WriteJSON(w http.ResponseWriter, statusCode int, data any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InternalServerError ¶
func InternalServerError(w http.ResponseWriter, err error)
InternalServerError writes a generic 500 response to the client and logs the real error server-side
func SetHeader ¶
func SetHeader(w http.ResponseWriter, key, value string)
SetHeader sets a response header with the given key and value
func Write ¶
func Write(w http.ResponseWriter, contentType string, statusCode int, data []byte)
Write writes a response with the given content type, status code, and data
func WriteError ¶
func WriteError(w http.ResponseWriter, statusCode int, err error)
WriteError writes an error response with the given status code and error
func WriteErrorMsg ¶
func WriteErrorMsg(w http.ResponseWriter, statusCode int, message string)
WriteErrorMsg writes an error response with the given status code and message
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.