Documentation
¶
Index ¶
- Constants
- Variables
- func SendError(c *fiber.Ctx, status int, err interface{}) error
- func SendErrorWithType(c *fiber.Ctx, status int, err interface{}, errorType models.ErrorType) error
- func SendSuccess(c *fiber.Ctx, status int, data interface{}) error
- type MetaResponse
- type Response
- type Server
- type ServerOptions
Constants ¶
const ( // OpenAIRequestTimeout is the maximum time to wait for OpenAI to respond OpenAIRequestTimeout = 15 * time.Second )
Added constant
Variables ¶
var ( // Note: Some errors might overlap with core definitions but are kept here // for mapping purposes within redirectToFrontend. ErrSessionNotFound = errors.New("session not found") ErrSessionExpired = errors.New("session expired") ErrUserNotFound = errors.New("user not found") ErrTeamNotFound = errors.New("team not found") ErrUserInactive = errors.New("user inactive") ErrOIDCProviderNotConfigured = errors.New("OIDC provider not configured") // This one might belong in auth/oidc.go ErrOIDCInvalidToken = errors.New("invalid OIDC token") ErrOIDCEmailNotVerified = errors.New("email not verified") )
Define Auth/OIDC specific errors used within handlers, especially for redirect mapping.
Functions ¶
func SendError ¶
SendError is a helper function to easily send a JSON error response with the given HTTP status code and error message. It uses the GeneralErrorType by default.
func SendErrorWithType ¶
SendErrorWithType is a helper function to easily send a JSON error response with the given HTTP status code, error message, and a specific application error type.
Types ¶
type MetaResponse ¶ added in v0.2.2
type MetaResponse struct {
Version string `json:"version"`
HTTPServerTimeout string `json:"http_server_timeout"`
}
MetaResponse represents the server metadata response
type Response ¶
type Response struct {
Status string `json:"status"` // "success" or "error"
Data interface{} `json:"data,omitempty"`
Message string `json:"message,omitempty"`
ErrorType string `json:"error_type,omitempty"` // Application-specific error type code.
}
Response defines the standard JSON structure for API responses.
func NewErrorResponse ¶
NewErrorResponse creates a standard error response structure. It accepts various error types and maps them to a consistent JSON format.
func NewSuccessResponse ¶
func NewSuccessResponse(data interface{}) Response
NewSuccessResponse creates a standard success response structure.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the core HTTP server, encapsulating the Fiber app instance and necessary dependencies like database connections and configuration.
func New ¶
func New(opts ServerOptions) *Server
New creates, configures, and returns a new Server instance. It initializes the Fiber application, sets up middleware, injects dependencies, and registers all application routes.
type ServerOptions ¶
type ServerOptions struct {
Config *config.Config
SQLite *sqlite.DB
ClickHouse *clickhouse.Manager
OIDCProvider *auth.OIDCProvider // OIDC provider for authentication flows.
FS http.FileSystem // Filesystem for serving static assets (frontend).
Logger *slog.Logger
BuildInfo string
Version string
}
ServerOptions holds the dependencies required to create a new Server instance. This structure reflects the refactored approach using direct dependencies instead of services.