From 3d967b586c8b277a5fd2ddc16289856205144036 Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Thu, 14 Nov 2024 00:27:43 +0100 Subject: Fix loading config --- config.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'config.go') diff --git a/config.go b/config.go index d9a2e30..746e437 100644 --- a/config.go +++ b/config.go @@ -1,6 +1,7 @@ package main import ( + "encoding" "encoding/base64" "encoding/json" "log" @@ -14,8 +15,21 @@ type userToken struct { Salt []byte `json:"salt"` } +type jsonURL url.URL + +func (u *jsonURL) UnmarshalText(v []byte) error { + parsed, err := url.Parse(string(v)) + if err != nil { + return err + } + *u = jsonURL(*parsed) + return nil +} + +var _ encoding.TextUnmarshaler = new(jsonURL) + type config struct { - CalendarURL url.URL `json:"calendar_url"` + CalendarURL jsonURL `json:"calendar_url"` Ignore ignoreRules `json:"ignore"` Port string `json:"port"` UserTokens map[string]userToken `json:"user_tokens"` -- cgit v1.2.3