render

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package render provides HTTP response serialization and standardized error formatting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RespondError

func RespondError(w http.ResponseWriter, err error)

RespondError serializes an error into the standard ResponseEnvelope with proper HTTP status.

func RespondJSON

func RespondJSON(w http.ResponseWriter, status int, data any, meta *MetaDetails)

RespondJSON serializes data and optional metadata into the standard ResponseEnvelope.

Types

type ErrorDetail

type ErrorDetail struct {
	Code    string         `json:"code"`
	Message string         `json:"message"`
	Details map[string]any `json:"details,omitempty"`
}

type MetaDetails

type MetaDetails struct {
	TotalCount int `json:"total_count,omitempty"`
	Limit      int `json:"limit,omitempty"`
	Offset     int `json:"offset,omitempty"`
}

type ResponseEnvelope

type ResponseEnvelope struct {
	Data  any          `json:"data"`
	Meta  *MetaDetails `json:"meta"`
	Error *ErrorDetail `json:"error"`
}

ResponseEnvelope represents the standardized JSON response envelope per PRD §14.5.

Jump to

Keyboard shortcuts

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