-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
halt
for instantly returning a response, interrupting current handler execution
#2374
Comments
halt
for instantly returning a response, interrupting current handler executionhalt
for instantly returning a response, interrupting current handler execution
You correctly point out that we have |
I was thinking more about naming. When using the So I was thinking if you want to return a response that is not an error itself, maybe a 204 if some condition happens and you don't want to deal with if/else conditions and including body and status in each of the if blocks. It's true that I can use Anyway, if you consider that this is not something you want for grape, it's totally fine :) feel free to close the issue. |
First, thank you. I (we) are open to suggestions and we absolutely should discuss it. Adding an API is a big deal so expect push back, but if you believe this is the right thing, keep arguing for it, don't give up so easily! A question, does this work? status 201
next Is Do you have an example where |
Hi @dblock ! Thanks for the suggestion :) really appreciated! I've just tried using the As I previously said, my issue/concern was more about naming, and as I've seen that other frameworks are using I was trying to build a example where the if something
status 201
header {}
body {}
next
end and to do something like this: halt!|success!|other!(201, {}, {}) if something So don't know if it reads significantly better, because at the end you need to manage if conditions as well. Totally open to add what you think that provides more value to the project, so at this point you have much more context and vision of the project than me. |
Good points. I think I'd like to hear what others have to say. |
Sure! Totally open to discuss it and to find the better approach :) I can wait a little bit to provide a PR to see if we hear from others. On the other hand, do you think that Thank you so much @dblock !! |
Hey 👋
Do you think a
halt
method can be interesting for instantly returning a response, interrupting current handler execution? An alternative toerror!
?Something like:
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!
The text was updated successfully, but these errors were encountered: