all repos — homestead @ 6ea2cb1bf25466e9dff577d605b4f103f1294723

Code for my website

config: convert base_url to a URL type

Alan Pearce
commit

6ea2cb1bf25466e9dff577d605b4f103f1294723

parent

2717b6b462724817bbecbda8ba2db934baf14f1d

1 file changed, 11 insertions(+), 1 deletion(-)

changed files
M internal/config/config.gointernal/config/config.go
@@ -3,6 +3,7 @@
import ( "io/fs" "log/slog" + "net/url" "github.com/BurntSushi/toml" "github.com/pkg/errors"
@@ -18,9 +19,18 @@ Name string
URL string `toml:"url"` } +type URL struct { + *url.URL +} + +func (u *URL) UnmarshalText(text []byte) (err error) { + u.URL, err = url.Parse(string(text)) + return err +} + type Config struct { DefaultLanguage string `toml:"default_language"` - BaseURL string `toml:"base_url"` + BaseURL URL `toml:"base_url"` RedirectOtherHostnames bool `toml:"redirect_other_hostnames"` Title string Email string