Documentation
¶
Overview ¶
Package http provides HTTP-related error utilities for the application.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetErrorFromRequest ¶
GetErrorFromRequest extracts an error from a failed HTTP request. It creates an appropriate error type based on the response status code.
func WriteError ¶
func WriteError(w http.ResponseWriter, err error)
WriteError writes an error response to the HTTP response writer. It sets the appropriate status code and content type, and writes the error as JSON.
func WriteErrorWithStatus ¶
func WriteErrorWithStatus(w http.ResponseWriter, err error, status int)
WriteErrorWithStatus writes an error response with a specific status code. This is useful when you want to override the default status code mapping.
Types ¶
type ErrorResponse ¶
type ErrorResponse struct {
// Code is the error code
Code string `json:"code,omitempty"`
// Message is the error message
Message string `json:"message,omitempty"`
// Details contains additional information about the error
Details map[string]interface{} `json:"details,omitempty"`
}
ErrorResponse represents an error response to be sent to clients.
Click to show internal directories.
Click to hide internal directories.