forked from mtusi2026/mtusi2026lab2
28 lines
447 B
Go
28 lines
447 B
Go
package config
|
|
|
|
import "os"
|
|
|
|
type Config struct {
|
|
Port string
|
|
DatabaseURL string
|
|
SessionTTLSeconds int
|
|
}
|
|
|
|
func Load() *Config {
|
|
port := os.Getenv("APP_PORT")
|
|
if port == "" {
|
|
port = "8080"
|
|
}
|
|
|
|
dbURL := os.Getenv("DATABASE_URL")
|
|
if dbURL == "" {
|
|
dbURL = "postgresql://postgres:postgres@postgres:5432/messenger"
|
|
}
|
|
|
|
return &Config{
|
|
Port: port,
|
|
DatabaseURL: dbURL,
|
|
SessionTTLSeconds: 3600,
|
|
}
|
|
}
|