Example #1
0
func init() {

	http.Handle("/auth/login", util.Chain(func(w http.ResponseWriter, r *http.Request) {
		id, found := util.RequestGetParam(r, "id")
		if found {
			bytes, _ := json.Marshal(util.Session{UserID: id})
			formatted := strings.Replace(string(bytes), ",", "|", -1)
			util.SetSessionInfo(w, formatted, 60*60*24)
		}
		http.Redirect(w, r, "/", http.StatusFound)
	}))

	http.Handle("/auth/logout", util.Chain(func(w http.ResponseWriter, r *http.Request) {
		util.SetSessionInfo(w, "", -1)
		http.Redirect(w, r, "/", http.StatusFound)
	}))
}
Example #2
0
func index(cfg *config.Config) http.Handler {
	return util.Chain(func(w http.ResponseWriter, r *http.Request) {
		if r.URL.Path != "/" {
			http.NotFound(w, r)
			return
		}
		util.RenderHTML(w, []string{"app/index.tmpl"}, controllers.CommonParams(w, r), nil)
	})
}
Example #3
0
func init() {
	http.Handle("/ec2/instances/", util.Chain(util.APIResourceHandler(ec2Instances{})))
}