Documentation
¶
Overview ¶
Package server provides the Fiber HTTP server with built-in middleware, TLS, and security features.
Index ¶
- func Duration(s string, fallback time.Duration) time.Duration
- type AutocertTLS
- type CORSConfig
- type Config
- type ContentSecurityConf
- type CorrelationConfig
- type CryptionConf
- type EncryptCookieConf
- type ErrorResponse
- type LocalStorage
- type ManualTLS
- type PoolConfig
- type Presigner
- type RouteConfig
- type S3Config
- type S3Storage
- func (s *S3Storage) Delete(ctx context.Context, key string) error
- func (s *S3Storage) Download(ctx context.Context, key string) (io.ReadCloser, error)
- func (s *S3Storage) PresignTTL() time.Duration
- func (s *S3Storage) PresignURL(ctx context.Context, key string, ttl time.Duration) (string, error)
- func (s *S3Storage) Upload(ctx context.Context, key string, reader io.Reader, size int64, ...) error
- type SecurityConfig
- type Server
- type SpoolConfig
- type SpooledFile
- type StorageBackend
- type TLSConfig
- type TelemetryConfig
- type UploadStreamer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AutocertTLS ¶ added in v0.1.0
type CORSConfig ¶
type Config ¶
type Config struct {
Port int
Host string
Prefork bool
BodyLimit int
Timeout time.Duration
ReadTimeout time.Duration
WriteTimeout time.Duration
IdleTimeout time.Duration
MaxConns int
MaxBytes int
MetricsPath string
HealthPath string
ShutdownTimeout time.Duration
RecoverStack bool
APIPrefix string
Routes []RouteConfig
Logger bool
LoadShedding bool
Breaker bool
Compression bool
StreamRequestBody bool
ReduceMemoryUsage bool
// Security
SecurityHeaders *middleware.SecurityHeadersConfig
CSRF *middleware.CSRFConfig
RateLimit *middleware.RateLimitConfig
TLS *TLSConfig
SSRF *middleware.SSRFConfig
// Correlation enables the X-Correlation-ID tracking middleware.
Correlation *CorrelationConfig
// Logger config
LogSkipPaths []string
LogSampleRate float64
}
func DefaultConfig ¶
func DefaultConfig() Config
type ContentSecurityConf ¶
type CorrelationConfig ¶ added in v0.11.0
type CryptionConf ¶
type EncryptCookieConf ¶ added in v0.8.0
type ErrorResponse ¶
type LocalStorage ¶
type LocalStorage struct {
// contains filtered or unexported fields
}
func NewLocalStorage ¶
func NewLocalStorage(root string) (*LocalStorage, error)
func (*LocalStorage) Download ¶
func (l *LocalStorage) Download(_ context.Context, key string) (io.ReadCloser, error)
type PoolConfig ¶ added in v0.6.0
type Presigner ¶ added in v0.6.0
type Presigner interface {
PresignURL(ctx context.Context, key string, ttl time.Duration) (string, error)
}
Presigner generates presigned URLs for direct client access. Optional extension of StorageBackend for S3-compatible storage.
type RouteConfig ¶
type S3Storage ¶
type S3Storage struct {
// contains filtered or unexported fields
}
func NewS3Storage ¶
func (*S3Storage) PresignTTL ¶ added in v0.9.0
func (*S3Storage) PresignURL ¶ added in v0.6.0
type SecurityConfig ¶
type SecurityConfig struct {
ContentSecurity *ContentSecurityConf
Cryption *CryptionConf
EncryptCookie *EncryptCookieConf
}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func New ¶
func New(cfg Config, telemetry TelemetryConfig, security SecurityConfig, corsCfg *CORSConfig) *Server
type SpoolConfig ¶ added in v0.17.0
type SpoolConfig struct {
Mode string
MemoryLimit int64
Dir string
PartSize int64
Concurrency int
Async bool
}
SpoolConfig drives streaming uploads: ingest the request body to memory (bounded by MemoryLimit) and then to local disk, before uploading the assembled file to the backend (S3) with multipart. All fields are YAML-driven via storage.spool.
Mode selects where the ingest buffer lives:
- "auto" (default): memory up to MemoryLimit, then spill to disk
- "memory": buffer entirely in RAM (small payloads)
- "disk": stream directly to a temp file, no RAM accumulation
type SpooledFile ¶ added in v0.17.0
SpooledFile is a streamed-to-disk payload ready for upload. The caller owns the file and must remove it after use (os.Remove on Path).
func SpoolToFile ¶ added in v0.17.0
func SpoolToFile(stream io.Reader, cfg SpoolConfig) (*SpooledFile, error)
SpoolToFile ingests the stream keeping at most cfg.MemoryLimit bytes in RAM; beyond that it spills to a temp file in cfg.Dir. The temp file is NOT removed here — the caller decides (immediate upload or async handoff).
type StorageBackend ¶
type StorageBackend interface {
Upload(ctx context.Context, key string, reader io.Reader, size int64, contentType string) error
Download(ctx context.Context, key string) (io.ReadCloser, error)
Delete(ctx context.Context, key string) error
}
StorageBackend abstracts file storage operations.
func NewSpooledStorage ¶ added in v0.17.0
func NewSpooledStorage(backend StorageBackend, cfg SpoolConfig) StorageBackend
NewSpooledStorage wraps a backend with spool-to-disk streaming uploads.
type TLSConfig ¶ added in v0.1.0
type TLSConfig struct {
Enabled bool `json:"enabled"`
Manual *ManualTLS `json:"manual" config:",optional"`
Autocert *AutocertTLS `json:"autocert" config:",optional"`
MinVersion string `json:"min_version" config:",optional"`
MaxVersion string `json:"max_version" config:",optional"`
CurvePrefs []string `json:"curve_preferences" config:",optional"`
CipherSuites []string `json:"cipher_suites" config:",optional"`
RedirectHTTP bool `json:"redirect_http" config:",optional"`
RedirectPort int `json:"redirect_port" config:",optional"`
}
type TelemetryConfig ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
auth
|
|
|
jwks
Package jwks provides JWKS key resolution for JWT signature validation.
|
Package jwks provides JWKS key resolution for JWT signature validation. |
|
openfga
Package openfga provides the OpenFGA authorization client.
|
Package openfga provides the OpenFGA authorization client. |
|
ory
Package ory provides Ory Kratos authentication and Keto authorization client.
|
Package ory provides Ory Kratos authentication and Keto authorization client. |
|
zitadel
Package zitadel provides Zitadel OIDC authentication and JWKS-based JWT validation.
|
Package zitadel provides Zitadel OIDC authentication and JWKS-based JWT validation. |
|
Package middleware provides Fiber HTTP middlewares for auth, security, validation, rate limiting, and more.
|
Package middleware provides Fiber HTTP middlewares for auth, security, validation, rate limiting, and more. |