dto

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package dto owns shared administrative HTTP response values.

Index

Constants

View Source
const (
	ErrorTypeInvalidRequest      = "invalid_request_error"
	ErrorTypeAuthenticationError = "authentication_error"
	ErrorTypePermissionError     = "permission_error"
	ErrorTypeNotFound            = "not_found_error"
	ErrorTypeRateLimit           = "rate_limit_error"
	ErrorTypeServerError         = "server_error"
	ErrorTypeServiceUnavailable  = "service_unavailable"
)

Common error types for OpenAI compatibility

Variables

This section is empty.

Functions

func WriteError

func WriteError(w http.ResponseWriter, status int, errType, message string)

WriteError writes an error response

func WriteJSON

func WriteJSON(w http.ResponseWriter, status int, data any) error

WriteJSON writes a JSON response

func WriteList added in v1.1.0

func WriteList(w http.ResponseWriter, status int, data any, nextCursor string) error

WriteList writes a cursor-paginated listing response.

func WriteValidationError

func WriteValidationError(w http.ResponseWriter, field, message string)

WriteValidationError writes a validation error response

Types

type ErrorDetail

type ErrorDetail struct {
	Message string  `json:"message"`
	Type    string  `json:"type"`
	Code    string  `json:"code,omitempty"`
	Param   *string `json:"param,omitempty"`
}

ErrorDetail contains error details

type ErrorResponse

type ErrorResponse struct {
	Error ErrorDetail `json:"error"`
}

ErrorResponse represents an API error response

type HealthResponse

type HealthResponse struct {
	Status    string `json:"status"`
	Timestamp string `json:"timestamp"`
	Service   string `json:"service,omitempty"`
	Version   string `json:"version,omitempty"`
}

HealthResponse represents a health check response

type ListResponse added in v1.1.0

type ListResponse struct {
	Data any `json:"data"`
	// NextCursor continues the listing; empty when the page is the last.
	NextCursor string `json:"next_cursor,omitempty"`
}

ListResponse is the shared envelope for cursor-paginated listings.

Jump to

Keyboard shortcuts

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