Allow response directly from callback
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 10k
- Forks
- 1.2k
- Avg merge
- 14h 38m
- Merged PRs (30d)
- 92
Description
I use Grape based application for PXE bare-metal server provisioning software. The main reason for which I use Grape for this is a very fast response time, resources lightweight, fault tolerance and REST API abilities which allows console client to communicate directly to provisioning server, without using another HTTP server library.
My application contains a large number of machine status checks, boot stage verification, connectivity checks and many other features for which I use mainly a Grape before callback. In this family of software machine communicates with Grape application multiple times during boot and it's a high chance that something will go wrong, eg. machine reboots or hangs between requests, caused by insufficient amount of RAM memory to boot received system image. For this exact example I use Grape before callback which ensures that the machine don't "go back" in boot process. In this and many another cases I need to return a response without executing requested HTTP function and without raising any exception in the application itself.
From what I see, Grape does not have this functionality, which forced me to make verification inside before callback block, and then return proper response in each HTTP method, depending on whether the verification was successful.
I very like to see function like return! or response! working in all callbacks, which will break code execution and immediately returns given response text, without calling any other callbacks. What do you think? This would help me a further development of the applications and greatly enhanced the readability of the code while reducing its vulnerability to coding errors.
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
Start by tracing how Grape executes before and other callbacks, then identify where a callback response could terminate request processing. Check the existing callback behavior and response handling before defining how return! or response! should behave; done means a callback can return the supplied response without running the endpoint or later callbacks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100