config

package
v0.0.0-...-a942fbd Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ModuleName = "build.local/misses/ldflags"               // e.g. "github.com/trino-network/pay-srv"
	Commit     = "< 40 chars git commit hash via ldflags >" // e.g. "59cb7684dd0b0f38d68cd7db657cb614feba8f7e"
	BuildDate  = "1970-01-01T00:00:00+00:00"                // e.g. "1970-01-01T00:00:00+00:00"
)

The following vars are automatically injected via -ldflags. See Makefile target "make go-build" and make var $(LDFLAGS). No need to change them here. https://www.digitalocean.com/community/tutorials/using-ldflags-to-set-version-information-for-go-applications

Functions

func GetFormattedBuildArgs

func GetFormattedBuildArgs() string

GetFormattedBuildArgs returns string representation of buildsargs set via ldflags "<ModuleName> @ <Commit> (<BuildDate>)"

Types

type AuthServer

type AuthServer struct {
	AccessTokenValidity          time.Duration
	PasswordResetTokenValidity   time.Duration
	DefaultUserScopes            []string
	LastAuthenticatedAtThreshold time.Duration
}

type Database

type Database struct {
	Host             string
	Port             int
	Username         string
	Password         string `json:"-"` // sensitive
	Database         string
	AdditionalParams map[string]string `json:",omitempty"` // Optional additional connection parameters mapped into the connection string
	MaxOpenConns     int
	MaxIdleConns     int
	ConnMaxLifetime  time.Duration
}

func (Database) ConnectionString

func (c Database) ConnectionString() string

ConnectionString generates a connection string to be passed to sql.Open or equivalents, assuming Postgres syntax

type EchoServer

type EchoServer struct {
	Debug                          bool
	ListenAddress                  string
	HideInternalServerErrorDetails bool
	BaseURL                        string
	EnableCORSMiddleware           bool
	EnableLoggerMiddleware         bool
	EnableRecoverMiddleware        bool
	EnableRequestIDMiddleware      bool
	EnableTrailingSlashMiddleware  bool
	EnableSecureMiddleware         bool
	EnableCacheControlMiddleware   bool
	SecureMiddleware               EchoServerSecureMiddleware
}

type EchoServerSecureMiddleware

type EchoServerSecureMiddleware struct {
	XSSProtection         string
	ContentTypeNosniff    string
	XFrameOptions         string
	HSTSMaxAge            int
	HSTSExcludeSubdomains bool
	ContentSecurityPolicy string
	CSPReportOnly         bool
	HSTSPreloadEnabled    bool
	ReferrerPolicy        string
}

EchoServerSecureMiddleware represents a subset of echo's secure middleware config relevant to the app server. https://github.com/labstack/echo/blob/master/middleware/secure.go

type FrontendServer

type FrontendServer struct {
	BaseURL               string
	PasswordResetEndpoint string
}

type I18n

type I18n struct {
	DefaultLanguage language.Tag
	BundleDirAbs    string
}

type LoggerServer

type LoggerServer struct {
	Level              zerolog.Level
	RequestLevel       zerolog.Level
	LogRequestBody     bool
	LogRequestHeader   bool
	LogRequestQuery    bool
	LogResponseBody    bool
	LogResponseHeader  bool
	PrettyPrintConsole bool
}

type Mailer

type Mailer struct {
	DefaultSender               string
	Send                        bool
	WebTemplatesEmailBaseDirAbs string
	Transporter                 string
}

type MailerTransporter

type MailerTransporter string
var (
	MailerTransporterMock MailerTransporter = "mock"
	MailerTransporterSMTP MailerTransporter = "SMTP"
)

func (MailerTransporter) String

func (m MailerTransporter) String() string

type ManagementServer

type ManagementServer struct {
	Secret                  string `json:"-"` // sensitive
	ReadinessTimeout        time.Duration
	LivenessTimeout         time.Duration
	ProbeWriteablePathsAbs  []string
	ProbeWriteableTouchfile string
}

type PathsServer

type PathsServer struct {
	APIBaseDirAbs string
	MntBaseDirAbs string
}

type PprofServer

type PprofServer struct {
	Enable                      bool
	EnableManagementKeyAuth     bool
	RuntimeBlockProfileRate     int
	RuntimeMutexProfileFraction int
}

type PushService

type PushService struct {
	UseFCMProvider  bool
	UseMockProvider bool
}

type Server

type Server struct {
	Database   Database
	Echo       EchoServer
	Pprof      PprofServer
	Paths      PathsServer
	Auth       AuthServer
	Management ManagementServer
	Mailer     Mailer
	SMTP       transport.SMTPMailTransportConfig
	Frontend   FrontendServer
	Logger     LoggerServer
	Push       PushService
	FCMConfig  provider.FCMConfig
	I18n       I18n
}

func DefaultServiceConfigFromEnv

func DefaultServiceConfigFromEnv() Server

DefaultServiceConfigFromEnv returns the server config as parsed from environment variables and their respective defaults defined below. We don't expect that ENV_VARs change while we are running our application or our tests (and it would be a bad thing to do anyways with parallel testing). Do NOT use os.Setenv / os.Unsetenv in tests utilizing DefaultServiceConfigFromEnv()! We can optimize here to do ENV_VAR parsing only once.

Jump to

Keyboard shortcuts

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