response

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

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.

type Response

type Response struct {
	Data  any `json:"data,omitempty"`
	Error any `json:"error,omitempty"`
	Meta  any `json:"meta,omitempty"`
}

Response represents a uniform JSON response structure

Jump to

Keyboard shortcuts

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