Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fully support PATCH like PUT and DELETE. #885

Merged
merged 1 commit into from
Sep 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion spec/http_method_override_handler_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ describe Lucky::HttpMethodOverrideHandler do
should_handle "POST", overridden_method: "", and_return: "POST"
end

it "overrides when POST with overridden PUT or DELETE" do
it "overrides when POST with overridden PATCH, PUT or DELETE" do
should_handle "POST", overridden_method: "patch", and_return: "PATCH"
should_handle "POST", overridden_method: "put", and_return: "PUT"
should_handle "POST", overridden_method: "delete", and_return: "DELETE"
end
Expand Down
2 changes: 1 addition & 1 deletion src/lucky/http_method_override_handler.cr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Lucky::HttpMethodOverrideHandler
end

private def override_allowed?(context, http_method) : Bool
["POST"].includes?(context.request.method) && ["PUT", "DELETE"].includes?(http_method)
["POST"].includes?(context.request.method) && ["PATCH", "PUT", "DELETE"].includes?(http_method)
end

private def overridden_http_method(context) : String?
Expand Down