func Get(key string, otherwise int) int {
	c := confHolder.Load().(conf)
	if v, ok := c[key]; ok {
		return v
	}
	return otherwise
}
Get retrieves the value from the configuration or, if it's not explicitly set, returns otherwise
package config
import (
	"fmt"
	"io/ioutil"
	"net/http"
	"strconv"
	"strings"
	"sync/atomic"
)
const (
	endpointPath = "/config"
)
type conf map[string]int
func copyConf(orig conf) conf {
	ret := make(conf)
	for k, v := range orig {
		ret[k] = v
	}
	return ret
}
var confHolder atomic.Value
func init() {
	confHolder.Store(make(conf))
	http.Handle(endpointPath, http.HandlerFunc(handleConfig))
	http.Handle(endpointPath+"/", http.HandlerFunc(handleConfig))
}
func handleConfig(w http.ResponseWriter, r *http.Request) {
	switch r.Method {
	case "GET":
		key := strings.TrimSpace(strings.TrimPrefix(r.URL.Path, endpointPath))
		c := confHolder.Load().(conf)
		if key == "" || key == "/" {
			for k, v := range c {
				fmt.Fprintf(w, "%s %d\n", k, v)
			}
		} else {
			key = key[1:]
			if v, ok := c[key]; ok {
				fmt.Fprintf(w, "%s %d\n", key, v)
			} else {
				w.WriteHeader(404)
			}
		}
	case "PUT":
		key := strings.TrimSpace(strings.TrimPrefix(r.URL.Path, endpointPath))
		if key == "" || key == "/" {
			w.WriteHeader(400)
			return
		}
		key = key[1:]
		raw, err := ioutil.ReadAll(r.Body)
		if err != nil {
			w.WriteHeader(500)
			return
		}
		r.Body.Close()
		v, err := strconv.Atoi(string(raw))
		if err != nil {
			w.WriteHeader(500)
			return
		}
		c := confHolder.Load().(conf)
		c = copyConf(c)
		c[key] = v
		confHolder.Store(c)
	default:
		w.WriteHeader(405)
	}
}