Documentation
¶
Index ¶
- func Error(w http.ResponseWriter, statusCode int, code, message string, details any)
- func SendJSON(w http.ResponseWriter, statusCode int, resp Response)
- func Success(w http.ResponseWriter, data any)
- func SuccessList(w http.ResponseWriter, items any, meta any)
- type ErrorInfo
- type ListMeta
- type Pagination
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Error ¶
func Error(w http.ResponseWriter, statusCode int, code, message string, details any)
Error sends an error response with structured error info
func SendJSON ¶
func SendJSON(w http.ResponseWriter, statusCode int, resp Response)
SendJSON sends a JSON response with the given status code
func Success ¶
func Success(w http.ResponseWriter, data any)
Success sends a successful response with data
func SuccessList ¶
func SuccessList(w http.ResponseWriter, items any, meta any)
SuccessList sends a list response whose Data is never omitted (so empty lists render as "data":[]) and whose optional Meta carries pagination. Use this for the agent v1 list endpoints instead of Success (see listResponse for the omitempty rationale).
Types ¶
type ErrorInfo ¶
type ErrorInfo struct {
Code string `json:"code"`
Message string `json:"message"`
Details any `json:"details,omitempty"`
}
ErrorInfo represents structured error information
type ListMeta ¶
type ListMeta struct {
Pagination Pagination `json:"pagination"`
}
ListMeta wraps pagination metadata under the canonical "pagination" key.
type Pagination ¶
type Pagination struct {
NextCursor string `json:"nextCursor,omitempty"`
HasMore bool `json:"hasMore"`
}
Pagination is the cursor-pagination metadata carried in a list response's meta. It is generic so the media list (Story 2.3) reuses the same envelope.