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()
}
