Documentation
¶
Index ¶
- func HandleAPIList(listFunc func() ([]map[string]interface{}, error)) http.HandlerFunc
- func HandleHealth() http.HandlerFunc
- func HandleReload(reloadFunc func() ([]string, error)) http.HandlerFunc
- func IsHTTPAddress(s string) bool
- func IsType(err error, errType ErrorType) bool
- type Config
- type ErrorType
- type HTTPContextFunc
- type ReloadResponse
- type ServerError
- func NewError(errType ErrorType, message string, details string) *ServerError
- func NewErrorWithContext(ctx context.Context, errType ErrorType, message string, details string) *ServerError
- func Wrap(err error, errType ErrorType, message string) *ServerError
- func WrapWithContext(ctx context.Context, err error, errType ErrorType, message string) *ServerError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleAPIList ¶
func HandleAPIList(listFunc func() ([]map[string]interface{}, error)) http.HandlerFunc
HandleAPIList handles listing available APIs
func HandleHealth ¶
func HandleHealth() http.HandlerFunc
HandleHealth handles the /health endpoint for health checks
func HandleReload ¶
func HandleReload(reloadFunc func() ([]string, error)) http.HandlerFunc
HandleReload handles the /reload endpoint for reloading API specifications
func IsHTTPAddress ¶
IsHTTPAddress checks if a string looks like an HTTP address
Types ¶
type Config ¶
type Config struct {
DatabaseMode bool
HTTPMode bool
HTTPAddr string
DatabaseURL string
Port int
SpecFiles []string
RequiredEnvVars map[string]string
}
Config holds server configuration
func LoadConfig ¶
LoadConfig loads configuration from environment variables and command line arguments
func (*Config) LogConfiguration ¶
func (c *Config) LogConfiguration()
LogConfiguration logs the current configuration
type ErrorType ¶
type ErrorType string
Error types for structured error handling
const ( ErrorTypeValidation ErrorType = "validation" ErrorTypeDatabase ErrorType = "database" ErrorTypeAuth ErrorType = "authentication" ErrorTypeNetwork ErrorType = "network" ErrorTypeInternal ErrorType = "internal" ErrorTypeNotFound ErrorType = "not_found" ErrorTypeConflict ErrorType = "conflict" )
type HTTPContextFunc ¶
type HTTPContextFunc func(context.Context, *http.Request, *openapi3.T, *models.OpenAPISpec) context.Context
HTTPContextFunc defines the function signature for HTTP context modification
func SecureAuthContextFunc ¶
func SecureAuthContextFunc(authStateManager *auth.StateManager) HTTPContextFunc
SecureAuthContextFunc creates a secure, request-scoped authentication context without global state mutation
type ReloadResponse ¶
type ReloadResponse struct {
Success bool `json:"success"`
ReloadedAPIs []string `json:"reloaded_apis,omitempty"`
Error string `json:"error,omitempty"`
}
ReloadResponse represents the response from a reload operation
type ServerError ¶
type ServerError struct {
Type ErrorType `json:"type"`
Message string `json:"message"`
Details string `json:"details,omitempty"`
RequestID string `json:"request_id,omitempty"`
Timestamp int64 `json:"timestamp"`
StackTrace string `json:"stack_trace,omitempty"`
}
ServerError represents a structured error with context
func NewError ¶
func NewError(errType ErrorType, message string, details string) *ServerError
NewError creates a new ServerError with context
func NewErrorWithContext ¶
func NewErrorWithContext(ctx context.Context, errType ErrorType, message string, details string) *ServerError
NewErrorWithContext creates a new ServerError with request context
func Wrap ¶
func Wrap(err error, errType ErrorType, message string) *ServerError
Wrap wraps a standard error as a ServerError
func WrapWithContext ¶
func WrapWithContext(ctx context.Context, err error, errType ErrorType, message string) *ServerError
WrapWithContext wraps a standard error as a ServerError with context
func (*ServerError) Error ¶
func (e *ServerError) Error() string
Error implements the error interface
func (*ServerError) LogError ¶
func (e *ServerError) LogError()
LogError logs the error with appropriate level and context
func (*ServerError) WithStackTrace ¶
func (e *ServerError) WithStackTrace() *ServerError
WithStackTrace adds stack trace information to the error