httputils

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

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

func NewHTTPClient(timeoutSeconds int) *http.Client

NewHTTPClient creates a new instance of a HTTP client configured with a timeout.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL