mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
Switch response envelope business code to numeric and make message consistently present. Add trace_id and optional details, and remove the duplicate DTO envelope definition. Improve middleware path exclusion handling and add a time-based trace ID fallback if crypto RNG fails. BREAKING CHANGE: response envelope `code` is now `int` (was `string`) and `message` semantics/defaults changed; clients must update parsing.
17 lines
739 B
Go
17 lines
739 B
Go
package api
|
|
|
|
// ResponseEnvelope is the standard wrapper for EZ-API JSON responses.
|
|
// Code is a numeric business code: 0 for success, non-zero for errors.
|
|
// Message is "success" for success, error description for failures.
|
|
// Data holds the original response payload for success; null for errors.
|
|
// TraceID is a request correlation identifier.
|
|
// Details holds optional structured error information.
|
|
// swagger:model ResponseEnvelope
|
|
type ResponseEnvelope struct {
|
|
Code int `json:"code" example:"0"`
|
|
Message string `json:"message" example:"success"`
|
|
Data any `json:"data" swaggertype:"object"`
|
|
TraceID string `json:"trace_id" example:"a1b2c3d4e5f6g7h8"`
|
|
Details any `json:"details,omitempty" swaggertype:"object"`
|
|
}
|