Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseJSON ¶
ParseJSON decodes the JSON request body into the provided payload. Returns an error if the request body is nil or the JSON is malformed.
func ReadJSON ¶
ReadJSON reads and returns the JSON data from the request body. It returns the JSON data as a byte slice and an error if any occur. It disallows unknown fields and limits the payload size to 1 MB.
func WriteError ¶
func WriteError(w http.ResponseWriter, status int, err error)
WriteError is a helper function to write an error response in JSON format. It sets the appropriate HTTP status code and provides a standardized error message.
Types ¶
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
ErrorResponse defines the structure for error messages returned to the client.
Click to show internal directories.
Click to hide internal directories.