show config to /config

This commit is contained in:
Christine Dodrill 2015-10-09 22:00:17 -07:00
parent d12499bcdd
commit 6bb3671a34
1 changed files with 26 additions and 2 deletions

View File

@ -1,8 +1,12 @@
package main
import (
"encoding/json"
"flag"
"fmt"
"net/http"
"github.com/Xe/middleware"
"github.com/codegangsta/negroni"
"shuo-irc.com/config"
)
@ -22,5 +26,25 @@ func main() {
panic(err)
}
fmt.Println("Hello world!")
_ = conf
mux := http.NewServeMux()
mux.HandleFunc("/config", func(rw http.ResponseWriter, req *http.Request) {
rw.Header().Set("Content-Type", "application/json")
body, err := json.MarshalIndent(conf, "", "\t")
if err != nil {
panic(err)
}
rw.Write(body)
})
n := negroni.Classic()
middleware.Inject(n)
n.UseHandler(mux)
n.Run(":" + conf.Info.Port)
}