diff options
author | Rutger Broekhoff | 2024-11-14 00:27:43 +0100 |
---|---|---|
committer | Rutger Broekhoff | 2024-11-14 00:27:43 +0100 |
commit | 3d967b586c8b277a5fd2ddc16289856205144036 (patch) | |
tree | 24318cd79b977bb03c1b9b7a7247d77fb87388d3 /config.go | |
parent | 14265a959cc3a527ab923731e121d08159872571 (diff) | |
download | icalproxy-3d967b586c8b277a5fd2ddc16289856205144036.tar.gz icalproxy-3d967b586c8b277a5fd2ddc16289856205144036.zip |
Fix loading config
Diffstat (limited to 'config.go')
-rw-r--r-- | config.go | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -1,6 +1,7 @@ | |||
1 | package main | 1 | package main |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "encoding" | ||
4 | "encoding/base64" | 5 | "encoding/base64" |
5 | "encoding/json" | 6 | "encoding/json" |
6 | "log" | 7 | "log" |
@@ -14,8 +15,21 @@ type userToken struct { | |||
14 | Salt []byte `json:"salt"` | 15 | Salt []byte `json:"salt"` |
15 | } | 16 | } |
16 | 17 | ||
18 | type jsonURL url.URL | ||
19 | |||
20 | func (u *jsonURL) UnmarshalText(v []byte) error { | ||
21 | parsed, err := url.Parse(string(v)) | ||
22 | if err != nil { | ||
23 | return err | ||
24 | } | ||
25 | *u = jsonURL(*parsed) | ||
26 | return nil | ||
27 | } | ||
28 | |||
29 | var _ encoding.TextUnmarshaler = new(jsonURL) | ||
30 | |||
17 | type config struct { | 31 | type config struct { |
18 | CalendarURL url.URL `json:"calendar_url"` | 32 | CalendarURL jsonURL `json:"calendar_url"` |
19 | Ignore ignoreRules `json:"ignore"` | 33 | Ignore ignoreRules `json:"ignore"` |
20 | Port string `json:"port"` | 34 | Port string `json:"port"` |
21 | UserTokens map[string]userToken `json:"user_tokens"` | 35 | UserTokens map[string]userToken `json:"user_tokens"` |