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 ¶
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.
Click to show internal directories.
Click to hide internal directories.