Open
Description
Hey 👋
Do you think a halt
method can be interesting for instantly returning a response, interrupting current handler execution? An alternative to error!
?
Something like:
class MyAPI < Grape::API
get '/wadus' do
halt 401 unless authenticated?
end
end
I think it can be useful and it's a standard. Also, it's present in some many other frameworks:
https://github.com/alisnic/nyny#request-scope
https://github.com/jeremyevans/roda/blob/master/lib/roda/plugins/halt.rb
https://github.com/hanami/controller#throwable-http-statuses
Thanks!