From 6a49024e0ba2f03578164bf64a7d15ac056e591b Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Mon, 19 Dec 2016 09:17:53 -0800 Subject: contin. debugging host port issue in config --- cmd/ponzu/main.go | 1 + system/db/config.go | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/ponzu/main.go b/cmd/ponzu/main.go index b2b5e75..b77b7c9 100644 --- a/cmd/ponzu/main.go +++ b/cmd/ponzu/main.go @@ -296,6 +296,7 @@ func main() { // save the port the system is listening on so internal system can make // HTTP api calls while in dev or production w/o adding more cli flags + fmt.Println(port, "port from main") err := db.PutConfig("http_port", fmt.Sprintf("%d", port)) if err != nil { log.Fatalln("System failed to save config. Please try to run again.") diff --git a/system/db/config.go b/system/db/config.go index 5cbdd2a..5122e41 100644 --- a/system/db/config.go +++ b/system/db/config.go @@ -137,9 +137,18 @@ func PutConfig(key string, value interface{}) error { data := make(url.Values) for k, v := range kv { switch v.(type) { + case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64: + data.Set(k, fmt.Sprintf("%d", v)) + + case float32, float64: + data.Set(k, fmt.Sprintf("%f", v)) + + case bool: + data.Set(k, fmt.Sprintf("%t", v)) + case string: - fmt.Println("type string:", v) data.Set(k, v.(string)) + case []string: vv := v.([]string) for i := range vv { @@ -149,6 +158,7 @@ func PutConfig(key string, value interface{}) error { data.Add(k, vv[i]) } } + default: log.Println("No type case for:", k, v, "in PutConfig") data.Set(k, fmt.Sprintf("%v", v)) -- cgit v1.2.3