package web import ( "fmt" "log" "net/http" "github.com/gorilla/mux" "github.com/spf13/viper" ) // Router creates the default http router func Router() *mux.Router { r := mux.NewRouter() r.HandleFunc("/", root) return r } func root(resp http.ResponseWriter, req *http.Request) { if req.URL.Path != "/" { http.NotFound(resp, req) return } fmt.Fprintf(resp, "Hello World!") } // RunServer runs the webserver with the router and middleware func RunServer() { router := Router() log.Fatal(http.ListenAndServe(viper.GetString("addr"), router)) }