util

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrParseRequestBody     = errors.New("failed to parse request body").WithCode("ERR_PARSE_REQUEST_BODY").WithKind(errors.KindInvalidInput)
	ErrMissingCorrelationID = errors.New("missing correlation id parameter").WithCode("ERR_MISSING_CORRELATION_ID").WithKind(errors.KindInvalidInput)
)

Functions

func WriteError

func WriteError(ctx context.Context, rw http.ResponseWriter, err error)

func WriteID added in v1.4.0

func WriteID(rw http.ResponseWriter, status int, id string)

func WriteMessage added in v1.3.0

func WriteMessage(rw http.ResponseWriter, status int, msg string)

func WriteResponse

func WriteResponse(rw http.ResponseWriter, status int, response any)

Types

type APIError

type APIError struct {
	Code      string         `example:"ERR_SOMETHING_WENT_WRONG" json:"code"`
	Message   string         `example:"Something went wrong"     json:"message"`
	Retryable bool           `example:"true"                     json:"retryable"`
	Details   map[string]any `json:"details,omitempty"`
}

func NewAPIError

func NewAPIError(err error) *APIError

func (*APIError) Error

func (e *APIError) Error() string

Jump to

Keyboard shortcuts

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