Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Ability to stop request and return result in before_request #86

Open
slbug opened this issue Mar 18, 2015 · 1 comment

Comments

@slbug
Copy link

slbug commented Mar 18, 2015

Something like this (returning false stops request):

class Post < ActiveRestClient::Base
  before_request :verify_something

  def verify_something(name, request, response)
    if some_condition?
      response.body = ''
      return false
    end

   true
  end
end

or call method to set request

class Post < ActiveRestClient::Base
  before_request :verify_something

  def verify_something(name, request)
    set_response('') if some_condition?
  end
end
@andyjeffries
Copy link
Contributor

For the first one, I would suggest just raising an exception (because if something happens to stop the request, you'd need to know that happened so you could correct it in the calling code anyway).

The second one I like the idea of. I don't have time to work on it at the moment, but I'd support it in principle. I'd prefer something like force_response('...') over set_ as I find set_ to be quite ugly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants