diff --git a/src/shuo-irc.com/cmd/scream/main.go b/src/shuo-irc.com/cmd/scream/main.go index b4a9869..1125432 100644 --- a/src/shuo-irc.com/cmd/scream/main.go +++ b/src/shuo-irc.com/cmd/scream/main.go @@ -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) }