Documentation
¶
Index ¶
- func PingPostgres(databaseURL, schema string) error
- type Option
- func WithAdminAPI(enabled bool) Option
- func WithCDNURLs(cdnBaseURL, uploadBaseURL string) Option
- func WithContentBasedURLs(apiBaseURL string) Option
- func WithDatabase(dbType, url string) Option
- func WithDatabaseSchema(schema string) Option
- func WithDefaultStorage(name string) Option
- func WithDefaults() Option
- func WithEnv(prefix string) Option
- func WithEnvironment(env string) Option
- func WithEventLogging(enabled bool) Option
- func WithFilesystemStorage(name, baseDir, urlPrefix, secretKey string) Option
- func WithFilesystemStorageExpiry(name string, expirySeconds int) Option
- func WithFilesystemStorageFull(name, baseDir, urlPrefix, secretKey string, expirySeconds int) Option
- func WithMemoryStorage(name string) Option
- func WithObjectKeyGenerator(generator string) Option
- func WithPort(port string) Option
- func WithPreviews(enabled bool) Option
- func WithS3Credentials(name, accessKeyID, secretAccessKey string) Option
- func WithS3Endpoint(name, endpoint string, useSSL, usePathStyle bool) Option
- func WithS3PresignDuration(name string, durationSeconds int) Option
- func WithS3Storage(name, bucket, region string) Option
- func WithS3StorageFull(name, bucket, region, accessKey, secretKey, endpoint string, ...) Option
- func WithStorageDelegatedURLs() Option
- type ServerConfig
- type ServiceConfig
- type StorageBackendConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PingPostgres ¶ added in v0.1.1
PingPostgres verifies connectivity to Postgres and optionally sets search_path for the session. It fails if the schema (when provided) does not exist.
Types ¶
type Option ¶ added in v0.1.7
type Option func(*ServerConfig) error
Option applies configuration to a ServerConfig instance.
func WithAdminAPI ¶ added in v0.1.28
WithAdminAPI enables or disables the admin API endpoints
func WithCDNURLs ¶ added in v0.1.28
WithCDNURLs configures CDN URL strategy with hybrid upload support
func WithContentBasedURLs ¶ added in v0.1.28
WithContentBasedURLs configures content-based URL strategy
func WithDatabase ¶ added in v0.1.28
WithDatabase configures the database backend
func WithDatabaseSchema ¶ added in v0.1.28
WithDatabaseSchema sets the database schema (for Postgres)
func WithDefaultStorage ¶ added in v0.1.28
WithDefaultStorage sets the default storage backend name
func WithDefaults ¶ added in v0.1.28
func WithDefaults() Option
WithDefaults is a convenience option that applies sensible defaults This is useful as a base before applying more specific options
func WithEnv ¶ added in v0.1.7
WithEnv applies environment variable overrides using the provided prefix.
Simplified environment variable mapping:
Server (cmd/server-configured only):
PORT - Server port (default: "8080") ENVIRONMENT - Runtime environment (default: "development")
Database:
DATABASE_URL - Connection string (e.g., "postgresql://user:pass@host/db")
If set with "postgresql://" prefix, automatically sets DATABASE_TYPE=postgres
If empty or "memory", uses in-memory database
Storage:
STORAGE_URL - Storage connection string (one of):
- "memory://" - In-memory storage (default)
- "file:///path/to/data" - Filesystem storage
- "s3://bucket?region=us-east-1" - S3 storage
That's it! Use programmatic config for advanced features.
func WithEnvironment ¶ added in v0.1.28
WithEnvironment sets the environment (development, production, testing)
func WithEventLogging ¶ added in v0.1.28
WithEventLogging enables or disables event logging
func WithFilesystemStorage ¶ added in v0.1.28
WithFilesystemStorage adds a filesystem storage backend If name is empty, defaults to "fs"
func WithFilesystemStorageExpiry ¶ added in v0.1.28
WithFilesystemStorageExpiry sets the presigned URL expiry for filesystem storage
func WithFilesystemStorageFull ¶ added in v0.1.28
func WithFilesystemStorageFull(name, baseDir, urlPrefix, secretKey string, expirySeconds int) Option
WithFilesystemStorageFull provides all filesystem storage configuration in one call
func WithMemoryStorage ¶ added in v0.1.28
WithMemoryStorage adds a memory storage backend (for testing) If name is empty, defaults to "memory"
func WithObjectKeyGenerator ¶ added in v0.1.28
WithObjectKeyGenerator sets the object key generation strategy Valid values: "git-like", "tenant-aware", "high-performance", "legacy"
func WithPreviews ¶ added in v0.1.28
WithPreviews enables or disables preview generation
func WithS3Credentials ¶ added in v0.1.28
WithS3Credentials sets AWS credentials for S3 storage
func WithS3Endpoint ¶ added in v0.1.28
WithS3Endpoint sets a custom S3 endpoint (for MinIO, LocalStack, etc.)
func WithS3PresignDuration ¶ added in v0.1.28
WithS3PresignDuration sets the presigned URL duration for S3 (in seconds)
func WithS3Storage ¶ added in v0.1.28
WithS3Storage adds an S3 storage backend If name is empty, defaults to "s3"
func WithS3StorageFull ¶ added in v0.1.28
func WithS3StorageFull(name, bucket, region, accessKey, secretKey, endpoint string, useSSL, usePathStyle bool) Option
WithS3StorageFull provides all S3 storage configuration in one call
func WithStorageDelegatedURLs ¶ added in v0.1.28
func WithStorageDelegatedURLs() Option
WithStorageDelegatedURLs configures storage-delegated URL strategy This delegates URL generation to the storage backends (e.g., presigned S3/FS URLs)
type ServerConfig ¶
type ServerConfig struct {
ServiceConfig
// Server-specific configuration
Port string
Environment string // development, production, testing
EnableAdminAPI bool // Enable admin API endpoints (requires authentication in production)
}
ServerConfig represents server configuration for the simple-content HTTP server (cmd/server-configured) This extends ServiceConfig with server-specific settings
func Load ¶ added in v0.1.7
func Load(opts ...Option) (*ServerConfig, error)
Load constructs a ServerConfig by applying the supplied options on top of library defaults.
func LoadServerConfig ¶
func LoadServerConfig() (*ServerConfig, error)
LoadServerConfig is a convenience function that loads configuration from environment variables. It applies the default config and then overlays environment variable settings.
func (*ServerConfig) BuildRepository ¶ added in v0.1.15
func (c *ServerConfig) BuildRepository() (simplecontent.Repository, error)
BuildRepository builds just the repository from configuration This is a convenience method that delegates to ServiceConfig.BuildRepository()
func (*ServerConfig) BuildService ¶
func (c *ServerConfig) BuildService() (simplecontent.Service, error)
BuildService creates a Service instance from the server configuration This is a convenience method that delegates to ServiceConfig.BuildService()
func (*ServerConfig) Validate ¶
func (c *ServerConfig) Validate() error
Validate validates the server configuration (includes service validation + server-specific checks)
type ServiceConfig ¶ added in v0.1.28
type ServiceConfig struct {
// Database configuration
DatabaseURL string
DatabaseType string // "memory", "postgres"
DBSchema string // Postgres schema to use (default: content)
// Storage configuration
DefaultStorageBackend string
StorageBackends []StorageBackendConfig
// Service options
EnableEventLogging bool
EnablePreviews bool
// URL generation
URLStrategy string // "cdn", "content-based", "storage-delegated"
CDNBaseURL string // Base URL for CDN strategy downloads (e.g., "https://cdn.example.com")
UploadBaseURL string // Base URL for CDN strategy uploads (e.g., "https://api.example.com" or "/api/v1")
APIBaseURL string // Base URL for content-based strategy (e.g., "/api/v1")
// Object key generation
ObjectKeyGenerator string // "default", "git-like", "tenant-aware", "legacy"
}
ServiceConfig represents service-level configuration for the simple-content library This is the core configuration used by applications embedding the library
func (*ServiceConfig) BuildRepository ¶ added in v0.1.28
func (c *ServiceConfig) BuildRepository() (simplecontent.Repository, error)
BuildRepository builds just the repository from configuration
func (*ServiceConfig) BuildService ¶ added in v0.1.28
func (c *ServiceConfig) BuildService() (simplecontent.Service, error)
BuildService creates a Service instance from the service configuration
func (*ServiceConfig) Validate ¶ added in v0.1.28
func (c *ServiceConfig) Validate() error
Validate validates the service configuration
type StorageBackendConfig ¶
type StorageBackendConfig struct {
Name string
Type string // "memory", "fs", "s3"
Config map[string]interface{}
}
StorageBackendConfig represents configuration for a storage backend