server

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Duration

func Duration(s string, fallback time.Duration) time.Duration

Types

type AutocertTLS added in v0.1.0

type AutocertTLS struct {
	Domains  []string `json:"domains"`
	Email    string   `json:"email"`
	CacheDir string   `json:"cache_dir" config:",optional"`
	Staging  bool     `json:"staging" config:",optional"`
}

type CORSConfig

type CORSConfig struct {
	Origins     []string
	Methods     []string
	Headers     []string
	Credentials bool
	MaxAge      int
}

type Config

type Config struct {
	Port            int
	Host            string
	Prefork         bool
	BodyLimit       int
	Timeout         time.Duration
	MaxConns        int
	MaxBytes        int
	MetricsPath     string
	HealthPath      string
	ShutdownTimeout time.Duration
	RecoverStack    bool
	APIPrefix       string
	Routes          []RouteConfig

	// Security
	SecurityHeaders *middleware.SecurityHeadersConfig
	CSRF            *middleware.CSRFConfig
	RateLimit       *middleware.RateLimitConfig
	TLS             *TLSConfig
	SSRF            *middleware.SSRFConfig
}

func DefaultConfig

func DefaultConfig() Config

type ContentSecurityConf

type ContentSecurityConf struct {
	Enabled   bool
	Strict    bool
	PublicKey string
}

type CryptionConf

type CryptionConf struct {
	Enabled bool
	Key     string
}

type ErrorResponse

type ErrorResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type LocalStorage

type LocalStorage struct {
	// contains filtered or unexported fields
}

func NewLocalStorage

func NewLocalStorage(root string) (*LocalStorage, error)

func (*LocalStorage) Delete

func (l *LocalStorage) Delete(ctx context.Context, key string) error

func (*LocalStorage) Download

func (l *LocalStorage) Download(ctx context.Context, key string) (io.ReadCloser, error)

func (*LocalStorage) Upload

func (l *LocalStorage) Upload(ctx context.Context, key string, reader io.Reader, _ int64, _ string) error

type ManualTLS added in v0.1.0

type ManualTLS struct {
	CertFile string `json:"cert_file"`
	KeyFile  string `json:"key_file"`
}

type RouteConfig

type RouteConfig struct {
	Path       string
	Middleware []string // middleware names: logger, shedding, breaker, maxconns, maxbytes, gunzip, prometheus, trace, cors, jwt, content_security, cryption
}

type S3Config

type S3Config struct {
	Endpoint        string
	Region          string
	Bucket          string
	AccessKeyID     string
	SecretAccessKey string
	UseSSL          bool
}

type S3Storage

type S3Storage struct {
	// contains filtered or unexported fields
}

func NewS3Storage

func NewS3Storage(cfg S3Config) (*S3Storage, error)

func (*S3Storage) Delete

func (s *S3Storage) Delete(ctx context.Context, key string) error

func (*S3Storage) Download

func (s *S3Storage) Download(ctx context.Context, key string) (io.ReadCloser, error)

func (*S3Storage) Upload

func (s *S3Storage) Upload(ctx context.Context, key string, reader io.Reader, size int64, contentType string) error

type SecurityConfig

type SecurityConfig struct {
	ContentSecurity *ContentSecurityConf
	Cryption        *CryptionConf
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(cfg Config, telemetry TelemetryConfig, security SecurityConfig, corsCfg *CORSConfig) *Server

func (*Server) App

func (s *Server) App() *fiber.App

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop()

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.

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

type TelemetryConfig struct {
	Enabled  bool
	Name     string
	Endpoint string
	Sampler  float64
	Batcher  string
}

Directories

Path Synopsis
auth
ory

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL