コード例 #1
0
func LogoutHandler(w http.ResponseWriter, r *http.Request) {
	defer errors.RecoverHttpErr(w)

	switch r.Method {
	case "POST":
		logoutPost(w, r)
	default:
		http.Error(w, "Bad Request", 400)
	}
}
コード例 #2
0
func UsersHandler(w http.ResponseWriter, r *http.Request) {
	defer errors.RecoverHttpErr(w)

	err := store.CheckAuth(r)
	errors.CheckHttpErr(err != nil, "Unauthorized", 401)

	switch r.Method {
	case "GET":
		usersGet(w, r)
	default:
		http.Error(w, "Bad Request", 400)
	}
}
コード例 #3
0
func OrganizationHandler(w http.ResponseWriter, r *http.Request) {
	defer errors.RecoverHttpErr(w)

	err := store.CheckAuth(r)
	errors.CheckHttpErr(err != nil, "Unauthorized", 401)

	switch r.Method {
	case "GET":
		organizationGet(w, r)
	case "POST":
		organizationPost(w, r)
	case "PUT":
		organizationPut(w, r)
	case "DELETE":
		organizationDelete(w, r)
	default:
		http.Error(w, "Bad Request", 400)
	}
}