response

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2025 License: MIT Imports: 0 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Message string `json:"message"` // User-facing error message
	Details string `json:"details"` // Developer debug info (optional)
}

type APIResponse

type APIResponse[T any] struct {
	Data  T         `json:"data,omitempty"`  // Success data
	Error *APIError `json:"error,omitempty"` // Error details (if any)
}

func Error

func Error(userMsg, devMsg string) APIResponse[any]

User-friendly error response

func Success

func Success[T any](data T) APIResponse[T]

Success response

func WrapError

func WrapError(userMsg string, err error) APIResponse[any]

Wrap multiple errors together

Jump to

Keyboard shortcuts

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