gorilla / mux

Package gorilla/mux is a powerful HTTP router and URL matcher for building Go web servers with 🦍
https://gorilla.github.io
BSD 3-Clause "New" or "Revised" License
20.93k stars 1.85k forks source link

[BUG] Inconsistent HTTP status code on query mismatch #712

Closed soheilrt closed 1 year ago

soheilrt commented 1 year ago

The logical behavior of a router should return an HTTP status code of 404 when a request fails to satisfy route validation logic. Previously, MUX was returning a 405 HTTP status code in some rare scenarios, which was not valid in its case.

For more info, See: https://github.com/gorilla/mux/issues/704

Fixes #704

Summary of Changes

  1. Clear the mismatch error of the previous validations on method match.
  2. Added related tests

PS: Make sure your PR includes/updates tests! If you need help with this part, just ask!

codecov[bot] commented 1 year ago

Codecov Report

Merging #712 (74ea253) into main (24c3e7f) will decrease coverage by 0.44%. The diff coverage is 100.00%.

:exclamation: Current head 74ea253 differs from pull request most recent head f0c4f4f. Consider uploading reports for the commit f0c4f4f to get more accurate results

@@            Coverage Diff             @@
##             main     #712      +/-   ##
==========================================
- Coverage   78.44%   78.01%   -0.44%     
==========================================
  Files           5        5              
  Lines         877      887      +10     
==========================================
+ Hits          688      692       +4     
- Misses        135      140       +5     
- Partials       54       55       +1     
Files Changed Coverage Δ
route.go 68.46% <100.00%> (-0.84%) :arrow_down:
soheilrt commented 1 year ago

Hey @coreydaley 👋 Is there anything that I can help you with in here?

coreydaley commented 1 year ago

@soheilrt Thank you for the pull request, we will prioritize it's review based on the priority/severity of the associated github issue during one of our upcoming community meetings.