config

package
v0.0.0-...-1ec896d Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CacheDefaults = Defaults{
	"cache.type": CacheTypeNone,
	"cache.ttl":  15 * time.Minute,
}
View Source
var DBDefaults = Defaults{
	"db.url":    "sqlite://file::memory:?cache=shared",
	"db.driver": ports.DriverSQLite,
}
View Source
var EncryptionDefaults = Defaults{
	"encryption.hash.type":       encryption.AlgorithmArgon2ID,
	"encryption.hash.iterations": uint32(3),
	"encryption.hash.threads":    uint8(3),
	"encryption.hash.memory":     uint32(64 * 1024),
	"encryption.cipher.type":     encryption.AlgorithmXChaCha20Poly1305,
}
View Source
var HTTPDefaults = Defaults{
	"http.server.hostname":          "",
	"http.server.port":              3498,
	"http.server.readheadertimeout": 5 * time.Second,
	"http.csrf.secret":              mustDefaultSecret(),
	"http.csrf.secure":              true,
	"http.csrf.samesite":            csrf.SameSiteStrictMode,
	"http.cookie.secure":            true,
}
View Source
var LoggingDefaults = Defaults{
	"logging.level":     logging.Var{},
	"logging.addsource": false,
}
View Source
var SessionDefaults = Defaults{
	"session.tokens.issuer":   "gophershare",
	"session.tokens.audience": "gophershare",
	"session.tokens.lifetime": 1 * time.Hour,
	"session.tokens.maxskew":  30 * time.Second,
	"session.store.type":      SessionStoreTypeNone,
	"session.store.ttl":       15 * time.Minute,
}

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	Logging    Logging
	HTTP       HTTP
	DB         DB
	Session    Session
	Encryption Encryption
	Storage    Storage
	Cache      CacheDriverProvider
}

func New

func New() *AppConfig

func (*AppConfig) Load

func (a *AppConfig) Load(opts ...Option) error

func (*AppConfig) LoadFrom

func (a *AppConfig) LoadFrom(r io.Reader, opts ...Option) error

type CacheDriverProvider

type CacheDriverProvider interface {
	Driver() (ports.CacheDriver, error)
}

type CacheType

type CacheType string
const (
	CacheTypeNone   CacheType = ""
	CacheTypeBadger CacheType = "badger"
	CacheTypeRedis  CacheType = "redis"
)

type CipherProvider

type CipherProvider interface {
	Cipher() (ports.Cipher, error)
}

type CookieConfig

type CookieConfig struct {
	Secure bool
}

type DB

type DB struct {
	Driver ports.Driver
	URL    string
}

func (DB) Client

func (d DB) Client() (*ent.Client, error)

func (DB) Migrator

func (d DB) Migrator() (ports.Migrator, *ent.Client, error)

type Defaults

type Defaults map[string]any

func MergeDefaults

func MergeDefaults(d ...Defaults) Defaults

func (Defaults) Apply

func (d Defaults) Apply(v *viper.Viper)

type Encryption

type Encryption struct {
	Hash   KeyDeriverProvider
	Cipher CipherProvider
}

type HTTP

type HTTP struct {
	Server ServerSpec
	CSRF   struct {
		Secret   string
		Secure   bool
		SameSite csrf.SameSiteMode
	}
	Cookie CookieConfig
}

type KeyDeriverProvider

type KeyDeriverProvider interface {
	KeyDeriver() (ports.KeyDeriver, error)
}

type Logging

type Logging struct {
	Level     logging.Var
	AddSource bool
	HTTP      struct {
		IncludeRequestHeaders  bool
		IncludeResponseHeaders bool
	}
}

func (*Logging) ConfigureLogging

func (l *Logging) ConfigureLogging()

type Option

type Option interface {
	Apply(v *viper.Viper)
}

func WithFlags

func WithFlags(fs *pflag.FlagSet) Option

type ServerSpec

type ServerSpec struct {
	Hostname          string
	Port              uint16
	ReadHeaderTimeout time.Duration
}

func (ServerSpec) Address

func (s ServerSpec) Address() string

type Session

type Session struct {
	Tokens SessionTokens
	Store  SessionStoreProvider
}

type SessionStore

type SessionStore struct {
	Type SessionStoreType
}

type SessionStoreProvider

type SessionStoreProvider interface {
	Store() (ports.SessionStore, error)
}

type SessionStoreType

type SessionStoreType string
const (
	SessionStoreTypeNone   SessionStoreType = ""
	SessionStoreTypeBadger SessionStoreType = "badger"
	SessionStoreTypeRedis  SessionStoreType = "redis"
)

type SessionTokens

type SessionTokens struct {
	KeySet      ports.KeySetManager
	ActiveKeyID string
	Issuer      string
	Audience    string
	Lifetime    time.Duration
	MaxSkew     time.Duration
}

func (SessionTokens) Requirements

func (SessionTokens) TokenBuilder

func (st SessionTokens) TokenBuilder() ports.SessionTokenBuilder

type Storage

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

func (Storage) ByKey

func (s Storage) ByKey(key string) (ports.FileSystem, error)

func (Storage) Default

func (s Storage) Default() (ports.FileSystem, error)

func (Storage) Thumbnails

func (s Storage) Thumbnails() (ports.FileSystem, error)

type StorageProvider

type StorageProvider interface {
	Storage() (ports.FileSystem, error)
}

type WithConfigFilePath

type WithConfigFilePath string

func (WithConfigFilePath) Apply

func (w WithConfigFilePath) Apply(v *viper.Viper)

Jump to

Keyboard shortcuts

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