summaryrefslogtreecommitdiff
path: root/lex-serve/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'lex-serve/main.go')
-rw-r--r--lex-serve/main.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/lex-serve/main.go b/lex-serve/main.go
index 07dba19..ac67ad4 100644
--- a/lex-serve/main.go
+++ b/lex-serve/main.go
@@ -11,10 +11,12 @@ import (
"net/url"
"os"
"strings"
+
+ "github.com/BurntSushi/toml"
)
-//go:embed countries.json
-var countriesJSON []byte
+//go:embed countries.toml
+var countriesTOML []byte
func main() {
log := slog.New(slog.NewTextHandler(os.Stderr, nil))
@@ -32,9 +34,13 @@ func main() {
}
var handler = handler{logger: log, domain: domain, lawsByCC: map[string]map[string]law{}}
- err := json.Unmarshal(countriesJSON, &handler.countries)
+ meta, err := toml.NewDecoder(bytes.NewReader(countriesTOML)).Decode(&handler.countries)
if err != nil {
- log.Error("failed to parse countries.json", Error(err))
+ log.Error("failed to parse countries.toml", Error(err))
+ os.Exit(1)
+ }
+ if len(meta.Undecoded()) != 0 {
+ log.Error("unknown keys in countries.toml", "keys", meta.Undecoded())
os.Exit(1)
}
@@ -169,7 +175,7 @@ type law struct {
type country struct {
Name string
- SearchURL string `json:"search_url"`
+ SearchURL string `toml:"search-url"`
}
func (c country) HasPlaceholder() bool {