Documentation
¶
Index ¶
- func BadRequest(c *gin.Context, message string)
- func Conflict(c *gin.Context, message string)
- func Created(c *gin.Context, data interface{})
- func Forbidden(c *gin.Context, message string)
- func InternalServerError(c *gin.Context, message string)
- func NoContent(c *gin.Context)
- func NotFound(c *gin.Context, message string)
- func NotImplemented(c *gin.Context, message string)
- func ProviderError(c *gin.Context, message string)
- func RateLimitError(c *gin.Context, message string)
- func RespondWithError(c *gin.Context, statusCode int, errorType ErrorType, message string)
- func RespondWithErrorCode(c *gin.Context, statusCode int, errorType ErrorType, message string, ...)
- func ServiceUnavailable(c *gin.Context, message string)
- func Success(c *gin.Context, data interface{})
- func Unauthorized(c *gin.Context, message string)
- type Content
- type CreateProviderRequest
- type ErrorDetail
- type ErrorResponse
- type ErrorType
- type Message
- type MessageRequest
- type MessageResponse
- type Server
- type UpdateProviderRequest
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BadRequest ¶
BadRequest sends a 400 Bad Request error
func InternalServerError ¶
InternalServerError sends a 500 Internal Server Error
func NotImplemented ¶
NotImplemented sends a 501 Not Implemented error
func ProviderError ¶
ProviderError sends a 502 Bad Gateway error for provider issues
func RateLimitError ¶
RateLimitError sends a 429 Too Many Requests error
func RespondWithError ¶
RespondWithError sends a standardized error response
func RespondWithErrorCode ¶
func RespondWithErrorCode(c *gin.Context, statusCode int, errorType ErrorType, message string, code string)
RespondWithErrorCode sends a standardized error response with error code
func ServiceUnavailable ¶
ServiceUnavailable sends a 503 Service Unavailable response
func Unauthorized ¶
Unauthorized sends a 401 Unauthorized error
Types ¶
type CreateProviderRequest ¶
type CreateProviderRequest struct {
Name string `json:"name" binding:"required"`
APIBaseURL string `json:"apiBaseUrl" binding:"required"`
APIKey string `json:"apiKey" binding:"required"`
Models []string `json:"models"`
Enabled bool `json:"enabled"`
}
Provider request/response structures
type ErrorDetail ¶
type ErrorDetail struct {
Message string `json:"message"`
Type ErrorType `json:"type"`
Code string `json:"code,omitempty"`
}
ErrorDetail contains error details
type ErrorResponse ¶
type ErrorResponse struct {
Error ErrorDetail `json:"error"`
}
ErrorResponse represents a standardized error response
type ErrorType ¶
type ErrorType string
ErrorType represents the type of error
const ( ErrorTypeInvalidRequest ErrorType = "invalid_request" ErrorTypeNotFound ErrorType = "not_found" ErrorTypeAuthentication ErrorType = "authentication_error" ErrorTypePermission ErrorType = "permission_error" ErrorTypeRateLimit ErrorType = "rate_limit_error" ErrorTypeProviderError ErrorType = "provider_error" ErrorTypeServerError ErrorType = "server_error" ErrorTypeNotImplemented ErrorType = "not_implemented" )
type Message ¶
type Message struct {
Role string `json:"role" binding:"required"`
Content string `json:"content" binding:"required"`
}
Message structure
type MessageRequest ¶
type MessageRequest struct {
Model string `json:"model" binding:"required"`
Messages []Message `json:"messages" binding:"required,min=1"`
MaxTokens int `json:"max_tokens,omitempty"`
Stream bool `json:"stream,omitempty"`
System string `json:"system,omitempty"`
}
Message request structure (Anthropic format)
type MessageResponse ¶
type MessageResponse struct {
ID string `json:"id"`
Type string `json:"type"`
Role string `json:"role"`
Content []Content `json:"content"`
Model string `json:"model"`
Usage Usage `json:"usage,omitempty"`
}
Message response structure
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the CCProxy HTTP server
func NewWithPath ¶
NewWithPath creates a new server instance with a specific config path