コード例 #1
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)
	}
}
コード例 #2
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)
	}
}