func eventCancel(w http.ResponseWriter, r *http.Request, t auth.Token) error {
	uuid := r.URL.Query().Get(":uuid")
	if !bson.IsObjectIdHex(uuid) {
		msg := fmt.Sprintf("uuid parameter is not ObjectId: %s", uuid)
		return &errors.HTTP{Code: http.StatusBadRequest, Message: msg}
	}
	objID := bson.ObjectIdHex(uuid)
	e, err := event.GetByID(objID)
	if err != nil {
		return &errors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
	}
	reason := InputValue(r, "reason")
	if reason == "" {
		return &errors.HTTP{Code: http.StatusBadRequest, Message: "reason is mandatory"}
	}
	scheme, err := permission.SafeGet(e.AllowedCancel.Scheme)
	if err != nil {
		return err
	}
	allowed := permission.Check(t, scheme, e.AllowedCancel.Contexts...)
	if !allowed {
		return permission.ErrUnauthorized
	}
	err = e.TryCancel(reason, t.GetUserName())
	if err != nil {
		if err == event.ErrNotCancelable {
			return &errors.HTTP{Code: http.StatusBadRequest, Message: err.Error()}
		}
		return err
	}
	w.WriteHeader(http.StatusNoContent)
	return nil
}
func eventCancel(w http.ResponseWriter, r *http.Request, t auth.Token) error {
	uuid := r.URL.Query().Get(":uuid")
	if !bson.IsObjectIdHex(uuid) {
		msg := fmt.Sprintf("uuid parameter is not ObjectId: %s", uuid)
		return &errors.HTTP{Code: http.StatusBadRequest, Message: msg}
	}
	objID := bson.ObjectIdHex(uuid)
	e, err := event.GetByID(objID)
	if err != nil {
		return &errors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
	}
	reason := InputValue(r, "reason")
	if reason == "" {
		return &errors.HTTP{Code: http.StatusBadRequest, Message: "reason is mandatory"}
	}
	scheme, err := permission.SafeGet(e.AllowedCancel.Scheme)
	if err != nil {
		return err
	}
	allowed := permission.Check(t, scheme, e.AllowedCancel.Contexts...)
	if !allowed {
		return permission.ErrUnauthorized
	}
	err = e.TryCancel(reason, t.GetUserName())
	if err != nil {
		if err == event.ErrNotCancelable {
			return &errors.HTTP{Code: http.StatusBadRequest, Message: err.Error()}
		}
		return err
	}
	w.WriteHeader(http.StatusNoContent)
	return nil
}
func eventCancel ( w http . ResponseWriter , r * http . Request , t auth . Token ) error { uuid := r . URL . Query ( ) . Get ( " " ) if ! bson . IsObjectIdHex ( uuid ) { msg := fmt . Sprintf ( " " , uuid ) return & errors . HTTP { Code : http . StatusBadRequest , Message : msg } } objID := bson . ObjectIdHex ( uuid ) e , err := event . GetByID ( objID ) if err != nil { return & errors . HTTP { Code : http . StatusNotFound , Message : err . Error ( ) } } reason := InputValue ( r , " " ) if reason == " " { return & errors . HTTP { Code : http . StatusBadRequest , Message : " " } } scheme , err := permission . SafeGet ( e . AllowedCancel . Scheme ) if err != nil { return err } allowed := permission . Check ( t , scheme , e . AllowedCancel . Contexts ... ) if ! allowed { return permission . ErrUnauthorized } err = e . TryCancel ( reason , t . GetUserName ( ) ) if err != nil { if err == event . ErrNotCancelable { return & errors . HTTP { Code : http . StatusBadRequest , Message : err . Error ( ) } } return err } w . WriteHeader ( http . StatusNoContent ) return nil }
// title: event cancel
// path: /events/{uuid}/cancel
// method: POST
// produce: application/json
// responses:
//   204: OK
//   400: Invalid uuid or empty reason
//   401: Unauthorized
//   404: Not found
title : event cancel path : / events / { uuid } / cancel method : POST produce : application / json responses : 204 : OK 400 : Invalid uuid or empty reason 401 : Unauthorized 404 : Not found