~xenrox/10man-api

e46e51643da219133bc64557e69138591d8c212b — Thorben Günther 1 year, 5 months ago 1b8a267
config: port -> http-address

The listen interface should be configurable too.
3 files changed, 7 insertions(+), 7 deletions(-)

M README.md
M config/config.go
M server.go
M README.md => README.md +2 -2
@@ 9,8 9,8 @@ Code for [10man](https://hub.xenrox.net/~xenrox/10man/) API.
Your config file should be placed at `/etc/10man-api/config`.

```
# Port
port 8080
# http listen address
http-address 127.0.0.1:8080
# Connection string for the database (required)
connection-string postgresql://user:pass@localhost/db?sslmode=disable
# Comma separated list of steamID64 for users that should become an admin

M config/config.go => config/config.go +4 -4
@@ 8,7 8,7 @@ import (
)

type Config struct {
	Port               string
	HTTPAddress        string
	DBConnectionString string
	LogLevel           string
	Admins             []string


@@ 23,12 23,12 @@ func ReadConfig(path string) (*Config, error) {

	config := new(Config)
	// Set default values
	config.Port = "8080"
	config.HTTPAddress = "127.0.0.1:8080"
	config.LogLevel = "info"

	d := cfg.Get("port")
	d := cfg.Get("http-address")
	if d != nil {
		if err := d.ParseParams(&config.Port); err != nil {
		if err := d.ParseParams(&config.HTTPAddress); err != nil {
			return nil, err
		}
	}

M server.go => server.go +1 -1
@@ 50,7 50,7 @@ func main() {
	http.Handle("/query", srv)

	go func() {
		logger.Fatal(http.ListenAndServe(":"+cfg.Port, nil))
		logger.Fatal(http.ListenAndServe(cfg.HTTPAddress, nil))
	}()

	shutdown(<-sigs, db, logger)