panel/shared/postgres.go

25 lines
536 B
Go
Raw Normal View History

2024-11-03 21:33:08 +01:00
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()
}