Documentation
¶
Overview ¶
Package dto owns shared administrative HTTP response values.
Index ¶
- Constants
- func WriteError(w http.ResponseWriter, status int, errType, message string)
- func WriteJSON(w http.ResponseWriter, status int, data any) error
- func WriteList(w http.ResponseWriter, status int, data any, nextCursor string) error
- func WriteValidationError(w http.ResponseWriter, field, message string)
- type ErrorDetail
- type ErrorResponse
- type HealthResponse
- type ListResponse
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" )
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 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.
Click to show internal directories.
Click to hide internal directories.