2021-03-09 08:05:07 +00:00
|
|
|
package config
|
|
|
|
|
2021-03-21 20:38:37 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/jackc/pgx/v4"
|
|
|
|
)
|
2021-03-09 08:05:07 +00:00
|
|
|
|
|
|
|
type Environment string
|
|
|
|
|
|
|
|
const (
|
|
|
|
Live Environment = "live"
|
|
|
|
Beta = "beta"
|
|
|
|
Dev = "dev"
|
|
|
|
)
|
|
|
|
|
|
|
|
type HMNConfig struct {
|
2021-03-27 21:10:11 +00:00
|
|
|
Env Environment
|
|
|
|
Addr string
|
|
|
|
BaseUrl string
|
|
|
|
Postgres PostgresConfig
|
|
|
|
Auth AuthConfig
|
2021-03-09 08:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type PostgresConfig struct {
|
|
|
|
User string
|
|
|
|
Password string
|
|
|
|
Hostname string
|
|
|
|
Port int
|
|
|
|
DbName string
|
2021-03-21 20:38:37 +00:00
|
|
|
LogLevel pgx.LogLevel
|
2021-04-06 06:10:15 +00:00
|
|
|
MinConn int32
|
|
|
|
MaxConn int32
|
2021-03-09 08:05:07 +00:00
|
|
|
}
|
|
|
|
|
2021-03-27 21:10:11 +00:00
|
|
|
type AuthConfig struct {
|
|
|
|
CookieDomain string
|
|
|
|
CookieSecure bool
|
|
|
|
}
|
|
|
|
|
2021-03-09 08:05:07 +00:00
|
|
|
func (info PostgresConfig) DSN() string {
|
|
|
|
return fmt.Sprintf("user=%s password=%s host=%s port=%d dbname=%s", info.User, info.Password, info.Hostname, info.Port, info.DbName)
|
|
|
|
}
|