Documentation
¶
Index ¶
- Constants
- Variables
- func DotEnvLoad(absolutePathToEnvFile string, setEnvFn envSetter) error
- func DotEnvTryLoad(absolutePathToEnvFile string, setEnvFn envSetter)
- func GetFormattedBuildArgs() string
- type AuthServer
- type Database
- type EchoServer
- type EchoServerSecureMiddleware
- type FrontendServer
- type I18n
- type LoggerServer
- type Mailer
- type MailerTransporter
- type ManagementServer
- type PathsServer
- type PprofServer
- type PushService
- type Server
- type Workflow
Constants ¶
const DatabaseMigrationTable = "migrations"
The DatabaseMigrationTable name is baked into the binary This setting should always be in sync with dbconfig.yml, sqlboiler.toml and the live database (e.g. to be able to test producation dumps locally)
Variables ¶
var ( ModuleName = "build.local/misses/ldflags" // e.g. "github.com/sebastianmacias/clientify_livechat" 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
var DatabaseMigrationFolder = filepath.Join(util.GetProjectRootDir(), "/migrations")
The DatabaseMigrationFolder (folder with all *.sql migrations). This settings should always be in sync with dbconfig.yaml and Dockerfile (the final app stage). It's expected that the migrations folder lives at the root of this project or right next to the app binary.
Functions ¶
func DotEnvLoad ¶
DotEnvLoad forcefully overrides ENV variables through the supplied .env file.
This mechanism should only be used **locally** to easily inject (gitignored) secrets into your ENV.
When running normally (not within tests): DotEnvLoad("/path/to/my.env.local", os.SetEnv)
For tests (and ENV var autoreset) use t.Setenv: DotEnvLoad("/path/to/my.env.test.local", func(k string, v string) error { t.Setenv(k, v); return nil })
func DotEnvTryLoad ¶
func DotEnvTryLoad(absolutePathToEnvFile string, setEnvFn envSetter)
DotEnvTryLoad forcefully overrides ENV variables through **a maybe available** .env file.
This function will always remain silent if a .env file does not exist! If we successfully apply an ENV file, we will log a warning. If there are any other errors, we will panic!
This mechanism should only be used **locally** to easily inject (gitignored) secrets into your ENV. Non-existing .env files are actually the **best case**.
When running normally (not within tests): DotEnvTryLoad("/path/tp/my.env.local", os.SetEnv)
For tests (and autoreset) use t.Setenv: DotEnvTryLoad("/path/to/my.env.test.local", func(k string, v string) error { t.Setenv(k, v); return nil })
func GetFormattedBuildArgs ¶
func GetFormattedBuildArgs() string
GetFormattedBuildArgs returns string representation of buildsargs set via ldflags "<ModuleName> @ <Commit> (<BuildDate>)"
Types ¶
type AuthServer ¶
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 ¶
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 LoggerServer ¶
type MailerTransporter ¶
type MailerTransporter string
var ( MailerTransporterMock MailerTransporter = "mock" MailerTransporterSMTP MailerTransporter = "SMTP" )
func (MailerTransporter) String ¶
func (m MailerTransporter) String() string
type ManagementServer ¶
type PathsServer ¶
type PprofServer ¶
type PushService ¶
type Server ¶
type Server struct {
Database Database
Workflow Workflow
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()!