Documentation
¶
Index ¶
- func DecodeRequestBody(w http.ResponseWriter, r *http.Request, payload any, logger core.Logger) bool
- func HTTPError(w http.ResponseWriter, statusCode int, message string)
- func HTTPErrorWithFields(w http.ResponseWriter, statusCode int, message string, fields map[string]any)
- func HTTPJSONResponse(w http.ResponseWriter, statusCode int, data any)
- func NewHTTPClient(timeoutSeconds int) *http.Client
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeRequestBody ¶
func DecodeRequestBody(w http.ResponseWriter, r *http.Request, payload any, logger core.Logger) bool
DecodeRequestBody decodes a JSON request body into the provided payload and returns true if an error occurred and a response has been sent to the client.
func HTTPError ¶
func HTTPError(w http.ResponseWriter, statusCode int, message string)
HTTPError writes http error responses with a message represented in a JSON object.
func HTTPErrorWithFields ¶
func HTTPErrorWithFields(w http.ResponseWriter, statusCode int, message string, fields map[string]any)
HTTPErrorWithFields writes http error responses with a message represented in a JSON object along with extra fields.
func HTTPJSONResponse ¶
func HTTPJSONResponse(w http.ResponseWriter, statusCode int, data any)
HTTPJSONResponse writes http response with a JSON body.
func NewHTTPClient ¶
NewHTTPClient creates a new instance of a HTTP client configured with a timeout.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.