httpx

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Failure

func Failure(w JSONWriter, statusCode int, err ErrorDetail)

Failure returns an error standardized response. Automatically extracts traceID from context if not provided.

func Success

func Success(w JSONWriter, data any)

Success returns a successful standardized response. Automatically extracts traceID from context if not provided.

Types

type ErrorDetail

type ErrorDetail struct {
	Code           string         `json:"code"`
	Message        string         `json:"message"`
	LocalizationID string         `json:"localization_id,omitempty"`
	Meta           map[string]any `json:"meta,omitempty"`
}

ErrorDetail represents standardized error information.

type GinResponseWriter

type GinResponseWriter struct {
	// contains filtered or unexported fields
}

GinResponseWriter implements JSONWriter for gin.Context.

func NewGinResponseWriter

func NewGinResponseWriter(c *gin.Context) *GinResponseWriter

NewGinResponseWriter creates a new GinResponseWriter.

func (*GinResponseWriter) JSON

func (w *GinResponseWriter) JSON(statusCode int, payload any)

JSON implements the JSONWriter interface for gin.Context.

type JSONWriter

type JSONWriter interface {
	JSON(statusCode int, payload any)
}

JSONWriter interface abstracts the JSON response writer.

type ResponseEnvelope

type ResponseEnvelope struct {
	Success bool         `json:"success"`
	Data    any          `json:"data,omitempty"`
	Error   *ErrorDetail `json:"error,omitempty"`
	TraceID string       `json:"trace_id"`
}

ResponseEnvelope represents a standardized API response.

Jump to

Keyboard shortcuts

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