config

package
v0.0.0-...-00d00b2 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CORSConfig

type CORSConfig struct {
	AllowedOrigins   []string `env:"ALLOWED_ORIGINS" env-default:"" env-description:"CORS allowed origins"`
	AllowedMethods   []string `env:"ALLOWED_METHODS" env-default:"" env-description:"CORS allowed method"`
	AllowedHeaders   []string `env:"ALLOWED_HEADERS" env-default:"" env-description:"CORS allowed headers"`
	ExposedHeaders   []string `env:"EXPOSED_HEADERS" env-default:"" env-description:"CORS exposed origins"`
	AllowCredentials bool     `env:"ALLOW_CREDENTIALS" env-default:"false" env-description:"CORS allow credentials"`
	MaxAge           int      `env:"MAX_AGE" env-default:"5" env-description:"CORS request cache max age"`
}

type Config

type Config struct {
	Server   ServerConfig   `env-prefix:"SERVER_"`
	Log      LogConfig      `env-prefix:"LOG_"`
	CORS     CORSConfig     `env-prefix:"CORS_"`
	Postgres PostgresConfig `env-prefix:"POSTGRES_"`
}

func New

func New(path string) (*Config, error)

type LogConfig

type LogConfig struct {
	Level string `env:"LEVEL" env-required:"" env-description:"log level"`
}

type PostgresConfig

type PostgresConfig struct {
	Username    string        `env:"USERNAME" env-required:"" env-description:"postgres username"`
	Password    string        `env:"PASSWORD" env-required:"" env-description:"postgres password"`
	Host        string        `env:"HOST" env-required:"" env-description:"postgres host"`
	Port        int           `env:"PORT" env-required:"" env-description:"postgres port"`
	Database    string        `env:"DATABASE" env-required:"" env-description:"postgres database"`
	SSLMode     string        `env:"SSL_MODE" env-required:"" env-description:"postgres ssl mode"`
	PingTimeout time.Duration `env:"PING_TIMEOUT" env-required:"" env-description:"postgres ping timeout"`
}

func (PostgresConfig) URI

func (c PostgresConfig) URI() string

type ServerConfig

type ServerConfig struct {
	Host            string        `env:"HOST" env-required:"" env-description:"server host"`
	Port            int           `env:"PORT" env-required:"" env-description:"server port"`
	ShutdownTimeout time.Duration `env:"SHUTDOWN_TIMEOUT" env-required:"" env-description:"graceful shutdown timeout"`
}

Jump to

Keyboard shortcuts

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