func (SessionResourceHooks) ApiDelete(res kit.Resource, id string, r kit.Request) kit.Response { if id != r.GetSession().GetStrId() { return kit.NewErrorResponse("permission_denied", "Permission denied", 403) } if err := res.Backend().Delete(r.GetSession()); err != nil { return kit.NewErrorResponse("db_delete_error", err, true) } return &kit.AppResponse{} }
func (a *App) RunMethod(name string, r kit.Request, responder func(kit.Response), withFinishedChannel bool) (chan bool, apperror.Error) { method := a.registry.Method(name) if method == nil { return nil, &apperror.Err{ Code: "unknown_method", Message: fmt.Sprintf("The method %v does not exist", name), } } if r.GetSession() == nil { session, err := a.UserService().StartSession(r.GetUser(), "") if err != nil { return nil, err } r.SetSession(session) } instance := NewMethodInstance(method, r, responder) if withFinishedChannel { c := make(chan bool) instance.finishedChannel = c return c, a.sessionManager.QueueMethod(r.GetSession(), instance) } else { return nil, a.sessionManager.QueueMethod(r.GetSession(), instance) } }