panel/shared/postgres.go
2024-11-03 15:33:08 -05:00

24 lines
536 B
Go

package shared
import (
"github.com/spf13/viper"
"net/url"
)
func GetPostgresURI() string {
postgresURI := url.URL{
Scheme: "postgresql",
User: url.UserPassword(viper.GetString("database.user"), viper.GetString("database.password")),
Host: viper.GetString("database.host"),
Path: viper.GetString("database.database"),
}
values := postgresURI.Query()
values.Add("sslmode", "disable")
values.Add("timezone", viper.GetString("database.tz"))
postgresURI.RawQuery = values.Encode()
return postgresURI.String()
}