httputils

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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