Author: Adam <git@apiote.xyz>
update config * remove fields obsoleted by OpenAPI spec * add listen address * change config path from bimba to szczanieckiej
config/config.go | 32 +++++++++++++++----------------- main.go | 2 +- server/router.go | 2 +-
diff --git a/config/config.go b/config/config.go index af768d6f4f8a7e66ab573be091c09a02346a390d..dc8b66368a0d2cb0c57bef89f4dc70dfe5c58ae7 100644 --- a/config/config.go +++ b/config/config.go @@ -11,11 +11,9 @@ // todo change to dirty type Config struct { - FeedsPath string - AdminContact string - RateLimited bool - Private bool - EnabledFeeds []string + FeedsPath string + EnabledFeeds []string + ListenAddress string } type result struct { @@ -56,14 +54,8 @@ e = strings.ReplaceAll(strings.Trim(e, " "), "\"", "") config.EnabledFeeds = append(config.EnabledFeeds, e) } } - if key == "admin_contact" { - config.AdminContact = strings.ReplaceAll(value, "\"", "") - } - if key == "rate_limited" { - config.RateLimited = value == "true" - } - if key == "private" { - config.Private = value == "true" + if key == "listen_address" { + config.ListenAddress = strings.ReplaceAll(value, "\"", "") } } args.config = config @@ -74,10 +66,16 @@ return gott.Tuple{args} } func Read(configPath string) (Config, error) { - input := gott.Tuple{result{ - configPath: configPath, - config: Config{EnabledFeeds: []string{}}, - }} + input := gott.Tuple{ + result{ + configPath: configPath, + config: Config{ + EnabledFeeds: []string{}, + FeedsPath: "/var/lib/szczanieckiej", + ListenAddress: ":51354", + }, + }, + } output, err := gott.NewResult(input). Bind(openFile). Map(scan). diff --git a/main.go b/main.go index c42a31b53833a73f06e35baca3a48a7363ebe2bb..05868e021a1f08fc8277ea1d26a2b490cddbc079 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,7 @@ if len(os.Args) == 1 { fmt.Println("bimba_server [-c <config>] <command> ") os.Exit(1) } - configFilePath := "/etc/bimba.toml" + configFilePath := "/etc/szczanieckiej.toml" command := os.Args[1] if os.Args[1] == "-c" { configFilePath = os.Args[2] diff --git a/server/router.go b/server/router.go index a26d6000f65a0139d1ba98e80af025eca752c751..e1cb64b774fde69d33f882705dfe45b2018af5a9 100644 --- a/server/router.go +++ b/server/router.go @@ -710,7 +710,7 @@ return uint(accept), nil } func Route(cfg config.Config, traffic *traffic.Traffic) *http.Server { - srv := &http.Server{Addr: ":51354"} // todo to config (both adr and port) + srv := &http.Server{Addr: cfg.ListenAddress} http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { accept, err := parseAccept(r.Header.Values("Accept"))