-
-
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
Use 200 as default status for deletes that reply with content #1550
Use 200 as default status for deletes that reply with content #1550
Conversation
68ce601
to
553331a
Compare
553331a
to
81cf0fb
Compare
👍 On the MR! I'm really thinking we should just use a helper that combines status + body false, like I suggested before in the discussion: def return_no_content
status 204
body false
end Why is this much better?
Also now we only set 204 on a delete when there is no body, this is just not consistent with other HTTP methods (why is delete so special?) |
@jthornec Add a paragraph about this to UPGRADING please? Consider the @LeFnord @namusyaka can you please pitch in here to make sure I don't merge something we don't want? |
I like this change because it looks like it corrects 1 specific bug: if there's a body on DELETE, don't return 204, but 200. I can live with that. Now, I do believe there're a lot of sensible arguments in #1549 around what to do "in general", notably the following does make sense to me too, but is maybe a bit more scary: if request.request_method == Grape::Http::Headers::POST
201
elsif @body.empty?
204
else
200
end |
@dblock Again why the magic behaviour for a specific method + no body returned? Helper would be more than sufficient. I keep bitching about this since I strongly feel this is magical and quite unexpected behaviour (what if i want to delete return nothing but want status 200, legacy clients for example?) I vote for helper only :D |
…s code and an empty body
…ehaviour and how it’s changed over the past few versions
I've updated this PR to include the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks again … 👍
@JanStevens I hear you. If we hadn't shipped this change in a previous version I would probably just say "you're right" and leave things as is. @LeFnord @namusyaka I need some help deciding. |
yes, l'll confirm this within a few hours. |
First of all, we have to apologize that that changes in the case were insufficient. Well, regarding this pull request, never this change is wrong.
As written here, this changes is reasonable (but it's not complete..).
It's true that there is no consistency. However, we should commit considering changes at 0.19.0. Therefore, I'd like to vote to both helper and this change. |
Thanks @namusyaka, @LeFnord? |
as I said here #1549 (comment), I see this as the best solution
good point, for that @dblock's suggestion for a general handling should be implemented but this can also be done in a different PR IMHO |
I am going to merge this. Lets let it sit for a bit on master. I'd like @JanStevens and @jthornec to at least confirm you're happy (enough) with this change. |
I'm happy with this change. My issues were that the formatter wasn't running, and the 204 with content might confuse my client. This fixes both of those things, and all my app's tests pass now, so I'm good to move forward with the upgrade once this gets released. |
Thanks @jthornec for the effort |
I am going to cut a release today. |
@dblock … 👍 cool, so I can run tests and cut new ones for grape-entity and grape-swagger |
And done. |
As per #1549, having deletes use 204 as the default status when a body is present causes some issues. Sending a 204 No Content with content will likely surprise some clients, and it causes the formatter to be skipped.
This PR adds a check for
@body.present?
so that we only default to 204 No Content when there's actually no content.