`halt` for instantly returning a response, interrupting current handler execution
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 10k
- Forks
- 1.2k
- Avg merge
- 14h 38m
- Merged PRs (30d)
- 92
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!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no repository files or tests; start by comparing the linked halt implementations with Grape's existing error! behavior. Clarify the intended interruption and response semantics before locating the relevant Grape entry points; done means the behavior is agreed and covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100