Ensure properly configured BaseUrl.

This commit is contained in:
Asaf Gartner 2021-05-04 12:24:31 +03:00
parent 71a46ba5a1
commit e14116c99f
2 changed files with 6 additions and 1 deletions

View File

@ -1,7 +1,9 @@
package config package config
var Config = HMNConfig{ var Config = HMNConfig{
Env: Dev, Env: Dev,
Addr: ":9001",
BaseUrl: "http://handmade.local:9001",
Postgres: PostgresConfig{ Postgres: PostgresConfig{
User: "hmn", User: "hmn",
Password: "password", Password: "password",

View File

@ -22,6 +22,9 @@ func init() {
if err != nil { if err != nil {
panic(oops.New(err, "could not parse base URL")) panic(oops.New(err, "could not parse base URL"))
} }
if parsed.Scheme == "" || parsed.Host == "" {
panic(oops.New(nil, "Website is misconfigured. Config should include a full BaseUrl (e.g. \"http://handmade.local:9001\")"))
}
baseUrlParsed = *parsed baseUrlParsed = *parsed
} }