show config to /config
This commit is contained in:
parent
d12499bcdd
commit
6bb3671a34
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue