Skip to content
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

Proposal/capture error 983 #987

Open
wants to merge 57 commits into
base: TestWrapResponseWriter
Choose a base branch
from

Conversation

ousloob
Copy link

@ousloob ousloob commented Mar 9, 2025

This PR adds error capturing capabilities to Chi's WrapResponseWriter interface, enabling middleware to track and log errors that coour during request handling.
(#983)

VojtechVitek and others added 30 commits August 8, 2023 08:18
Co-authored-by: lutherwaves <git config --global user.email>
patrislav and others added 27 commits June 28, 2024 16:29
* middleware: add Discard method to WrapResponseWriter

* resolve review comments

* use ioutil.Discard and deprecate the public interface

* move the Discard method back to the public interface

* discard calls to WriteHeader too
* Add Find to Routes interface

* Add example of using Routes.Find

* Rename find-pattern example

* And find_pattern middleware

* Refactor find-pattern example to use official FindPattern middleware

* Remove middleware.FindPattern for now

---------

Co-authored-by: jriddle <[email protected]>
Co-authored-by: Vojtech Vitek <[email protected]>
* feat(): add CF-Connection-IP

* feat(): custom real ip header

go-chi#908

* fix(): typo

* refactor(): remove cf-connecting-ip from default headers

* refactor(): back to unexported default headers
The comment was meant to demonstrate how non-wildcard routes can match
wilecard routes, but there was likely a typo that made it incorrect.
* Fix condition in TestRedirectSlashes

* Improve test logs in middleware/strip_test.go

---------

Co-authored-by: Vojtech Vitek <[email protected]>
…o-chi#571)

* Fix typo in doc comment for Throttle middleware

* Add ability to specify response HTTP status code for Throttle middleware
* Fix Mux.Find not correctly handling nested routes

* Add more test cases for TextMuxFind

* Fix Mux.Find returning partial path for failing cases
Informational status in the range 100-199 may be sent multiple times, unlike statuses in the range 200-599.

This follows usage in the stdlib:
https://github.com/golang/go/blob/485ed2fa5b5e0b7067ef72a0f4bdc9ca12b77ed7/src/net/http/server.go#L1216
Now that we're 1.20+ instead of 1.14+ we can use 1.18's strings.Cut in a
few places to simplify code.
This is a new go vet analysis pass that fires under go 1.24:

  $ go1.24rc2 vet ./...
  # github.com/go-chi/chi/v5
  # [github.com/go-chi/chi/v5]
  ./mux_test.go:236:12: non-constant format string in call to (*testing.common).Fatalf
  ...

The strings would be parsed as format strings which is not intended.
See golang/go#60529 for details.
This also bumps the minimum supported version of Go to 1.16 (which itself has beel EOL for almost 3 years now)

Co-authored-by: Vojtech Vitek (golang.cz) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.