Add devweb support for auto-reloading webapp.

This commit is contained in:
2014-04-12 15:31:53 -07:00
parent 14bd95851c
commit 803913523e
4 changed files with 132 additions and 16 deletions

33
cmd/reloader/reloader.go Normal file
View File

@@ -0,0 +1,33 @@
package main
import (
"flag"
"net/http"
"code.google.com/p/rsc/devweb/slave"
"github.com/golang/glog"
"xinu.tv/email/db"
"xinu.tv/email/handlers"
)
func main() {
flag.Parse()
defer glog.Flush()
c, err := db.NewConn("")
if err != nil {
glog.Fatal(err)
}
h := handlers.Handlers(c)
// Mount the app's mux at / so the default http server will handle them.
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
h.ServeHTTP(w, r)
// Useful when debugging, flush logs after every request.
glog.Flush()
})
slave.Main()
}