Documentation
¶
Index ¶
- func InitLogger()
- func IsDuplicateKey(err error) bool
- func Migrate(db *sql.DB) error
- func MigrateDown(db *sql.DB) error
- func MigrateStatus(db *sql.DB) error
- func NewPool(ctx context.Context, databaseURL string) (*pgxpool.Pool, error)
- func OpenDB(databaseURL string) (*sql.DB, error)
- func RequestLogger(next http.Handler) http.Handler
- func RunMigrations(ctx context.Context, pool *pgxpool.Pool) error
- type Config
- type Storage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitLogger ¶
func InitLogger()
InitLogger configures zerolog. When LOG_FORMAT=pretty (or LOG_PRETTY=true), uses colorized console output for development. Otherwise outputs JSON for production/log aggregation.
func IsDuplicateKey ¶
IsDuplicateKey returns true if err is a Postgres unique-violation (SQLSTATE 23505).
func MigrateDown ¶
func MigrateStatus ¶
func RequestLogger ¶
RequestLogger is a Chi-compatible middleware that logs every request using zerolog. Logs method, path, status, duration, and remote IP.
Types ¶
type Config ¶
type Config struct {
DatabaseURL string
StoragePath string
ListenAddr string
APIKey string
DisableSignup bool
GitHubToken string
}
Config holds all runtime configuration for the skael server.
func LoadConfig ¶
LoadConfig reads configuration from environment variables. DATABASE_URL is required; returns an error if absent. API_KEY is optional but deprecated — user accounts and personal API keys are preferred. STORAGE_PATH defaults to "./data/skills"; LISTEN_ADDR defaults to ":8080". DISABLE_SIGNUP=true prevents new user registrations.
type Storage ¶
type Storage struct {
BasePath string
}
Storage provides local filesystem storage for skill archive files.
func NewStorage ¶
NewStorage creates a Storage rooted at basePath, creating the directory if it does not already exist.
func (*Storage) Read ¶
func (s *Storage) Read(name string) (io.ReadCloser, error)
Read opens the file stored under name (relative to BasePath) for reading. The caller is responsible for closing the returned ReadCloser.