Documentation
¶
Overview ¶
Package response provides standardised JSON envelope types for REST APIs consumed by frontend clients (React, Vue, Angular, etc.).
All responses share a consistent shape so the frontend can handle them generically without per-endpoint parsing logic.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Created ¶
func Created[T any](w http.ResponseWriter, data T)
Created writes a 201 JSON envelope around data.
Types ¶
type Envelope ¶
Envelope is the standard success wrapper for single-resource responses.
{ "data": <T>, "meta": { ... } }
type Meta ¶
type Meta struct {
RequestID string `json:"request_id,omitempty"`
Version string `json:"version,omitempty"`
}
Meta holds optional response metadata (e.g. request ID, version).
type Page ¶
type Page[T any] struct { Data []T `json:"data"` Pagination Pagination `json:"pagination"` }
Page is the standard wrapper for paginated list responses.
{ "data": [...], "pagination": { "page": 1, "per_page": 20, "total": 100, "total_pages": 5 } }
Click to show internal directories.
Click to hide internal directories.