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
Open
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
bfe3393
Fix GoDoc link to lead to the v5 module documentation (#834)
VojtechVitek Aug 8, 2023
1129e36
Go 1.21 in ci (#838)
pkieltyka Aug 8, 2023
f250983
remove mute conversion from Router to *Mux (#863)
TheRandomCharacter Oct 18, 2023
834f94d
Removes ambiguity around "fresh middleware stack" in GoDoc (#862)
TheRandomCharacter Oct 18, 2023
779d661
chore: unnecessary guard around call to delete (#859)
testwill Oct 18, 2023
355dd04
Fix typos in comments and variable names (#849)
alexandear Oct 18, 2023
f4ab9b1
fix: #846 (#847)
AthfanFasee Oct 19, 2023
3954a76
feat(middleware): add sunset/deprecation header middleware (#844)
thedevsaddam Oct 19, 2023
247397c
Use original expvar handler for profiler middleware (#848)
SergeyPodgornyy Oct 19, 2023
ecd1897
Refactor: drop else statements where if block ends with a return (#865)
alexandear Oct 19, 2023
9920283
Reformat godoc comments according to the latest Go (#867)
alexandear Oct 19, 2023
beeb541
Update _examples/logging source to point at go-chi/httplog
pkieltyka Oct 21, 2023
58ca6d6
middleware: new SupressNotFound handler
pkieltyka Oct 22, 2023
2452954
bump setup-go and checkout action versions (#885)
purificant Dec 17, 2023
9dd8b4a
reset methodsAllowed on contexts in sync pool
pkieltyka Dec 20, 2023
87caec0
Create SECURITY.md
pkieltyka Dec 20, 2023
fcdb132
v5.0.11
pkieltyka Dec 20, 2023
f6b97ed
doc: add Sunset middleware in readme (#893)
thedevsaddam Jan 10, 2024
7446950
Extend Handle method to parse HTTP method in pattern (#897)
Spartan09 Jan 18, 2024
bec368a
Fix a typo in maybe middleware doc (#889)
gromms Jan 23, 2024
9436cc8
go 1.22 ci (#898)
pkieltyka Feb 11, 2024
60b4f5f
feat: update HTTP method parsing in patterns for `Handle` and `Handle…
angelofallars Feb 17, 2024
fd0ff0e
feat(mux): add 1.22-style path value support (#901)
angelofallars Feb 17, 2024
ec67a86
go 1.22, PathValue wildcard test
pkieltyka Feb 17, 2024
1191921
v5.0.12
pkieltyka Feb 17, 2024
c1f2a7a
middleware: fix typo in RealIP doc (#903)
l2dy Mar 31, 2024
ef31c0b
reduce context struct size from 216 bytes to 208 bytes (#912)
juburr May 7, 2024
f10dc4a
fix(middleware): Close created writer in the compressor middleware (#…
Neurostep Jun 7, 2024
f728a1c
docs: Update stale links in docs for contributing (#904)
Lutherwaves Jun 19, 2024
7957c0d
Revert "fix(middleware): Close created writer in the compressor middl…
VojtechVitek Jun 21, 2024
67be7d9
middleware: add Discard method to WrapResponseWriter (#926)
patrislav Jun 28, 2024
eb01474
update credits section to link to goji license (#944)
pkieltyka Aug 20, 2024
dac67d9
go 1.23 (#945)
pkieltyka Aug 23, 2024
6fedde2
Make Context.RoutePattern() nil-safe (#927)
gaiaz-iusipov Aug 23, 2024
39703bc
govet: Fix non-constant format string (#952)
marcofranssen Sep 17, 2024
1089a7c
Add `Find` to `Routes` interface (#872)
joeriddles Sep 18, 2024
134f373
Fix grammar error (#917)
AntonC9018 Sep 18, 2024
cbaac31
feat(): add CF-Connecting-IP (#908)
n33pm Sep 18, 2024
df0303d
Fixed incorrect comment about routing (#887)
jtams Sep 18, 2024
7335050
Fix condition in TestRedirectSlashes (#856)
tchssk Sep 18, 2024
5dd7716
add strip prefix. (#875)
m1k1o Sep 18, 2024
2c4d128
set up go module for _examples/versions (#948)
hongkuancn Sep 18, 2024
1f927a8
Ability to specify response HTTP status code for Throttle middleware …
vasayxtx Sep 18, 2024
882c15e
Update content_type.go (#880)
GocaMaric Sep 18, 2024
6ceb498
Fix `Mux.Find` not correctly handling nested routes (#954)
joeriddles Sep 26, 2024
d9d5e31
fix: allow multiple informational status (#961)
costela Dec 14, 2024
0a20a0e
Revert "feat(): add CF-Connecting-IP (#908)" (#966)
VojtechVitek Dec 14, 2024
71307f9
Support the four most recent major versions of Go (#969)
VojtechVitek Jan 20, 2025
877e876
Use strings.Cut in a few places (#971)
JRaspass Feb 4, 2025
72fbe46
Fix non-constant format strings in t.Fatalf (#972)
JRaspass Feb 5, 2025
e846b83
Apply fieldalignment fixes to optimize struct memory layout (#974)
pixel365 Feb 5, 2025
c6225e3
go 1.24 (#977)
pkieltyka Feb 11, 2025
1aae5b2
chore: delint ioutil usage (#962)
costela Feb 12, 2025
fe2c065
Fixed the typo (#958)
mithileshgupta12 Feb 12, 2025
d047034
support tinygo (#978)
efraimbart Feb 18, 2025
d7034fd
Exclude profiler when use tinygo (#982)
cxjava Feb 18, 2025
006bf80
prototype CaptureErr into WrapResponseWriter interface (go-chi#983)
ousloob Mar 9, 2025
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
Prev Previous commit
Next Next commit
Fix typos in comments and variable names (#849)
alexandear authored Oct 18, 2023
commit 355dd04bad970f83ad19dc6856bc209f2402732d
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -306,7 +306,7 @@ Cheers all, happy coding!
request-scoped values. We're very excited about the new context addition and are proud to
introduce chi v2, a minimal and powerful routing package for building large HTTP services,
with zero external dependencies. Chi focuses on idiomatic design and encourages the use of
stdlib HTTP handlers and middlwares.
stdlib HTTP handlers and middlewares.
- chi v2 deprecates its `chi.Handler` interface and requires `http.Handler` or `http.HandlerFunc`
- chi v2 stores URL routing parameters and patterns in the standard request context: `r.Context()`
- chi v2 lower-level routing context is accessible by `chi.RouteContext(r.Context()) *chi.Context`,
2 changes: 1 addition & 1 deletion _examples/versions/main.go
Original file line number Diff line number Diff line change
@@ -118,7 +118,7 @@ func getArticle(w http.ResponseWriter, r *http.Request) {
}

// Simulate some context values:
// 1. ?auth=true simluates authenticated session/user.
// 1. ?auth=true simulates authenticated session/user.
// 2. ?error=true simulates random error.
if r.URL.Query().Get("auth") != "" {
r = r.WithContext(context.WithValue(r.Context(), "auth", true))
2 changes: 1 addition & 1 deletion context.go
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ type Context struct {
URLParams RouteParams

// Route parameters matched for the current sub-router. It is
// intentionally unexported so it cant be tampered.
// intentionally unexported so it can't be tampered.
routeParams RouteParams

// The endpoint routing pattern that matched the request URI path
14 changes: 7 additions & 7 deletions middleware/compress.go
Original file line number Diff line number Diff line change
@@ -197,7 +197,7 @@ func (c *Compressor) Handler(next http.Handler) http.Handler {
contentTypes: c.allowedTypes,
contentWildcards: c.allowedWildcards,
encoding: encoding,
compressable: false, // determined in post-handler
compressible: false, // determined in post-handler
}
if encoder != nil {
cw.w = encoder
@@ -271,10 +271,10 @@ type compressResponseWriter struct {
contentWildcards map[string]struct{}
encoding string
wroteHeader bool
compressable bool
compressible bool
}

func (cw *compressResponseWriter) isCompressable() bool {
func (cw *compressResponseWriter) isCompressible() bool {
// Parse the first part of the Content-Type response header.
contentType := cw.Header().Get("Content-Type")
if idx := strings.Index(contentType, ";"); idx >= 0 {
@@ -306,13 +306,13 @@ func (cw *compressResponseWriter) WriteHeader(code int) {
return
}

if !cw.isCompressable() {
cw.compressable = false
if !cw.isCompressible() {
cw.compressible = false
return
}

if cw.encoding != "" {
cw.compressable = true
cw.compressible = true
cw.Header().Set("Content-Encoding", cw.encoding)
cw.Header().Add("Vary", "Accept-Encoding")

@@ -330,7 +330,7 @@ func (cw *compressResponseWriter) Write(p []byte) (int, error) {
}

func (cw *compressResponseWriter) writer() io.Writer {
if cw.compressable {
if cw.compressible {
return cw.w
} else {
return cw.ResponseWriter
2 changes: 1 addition & 1 deletion middleware/realip_test.go
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ func TestXForwardForXRealIPPrecedence(t *testing.T) {
}
}

func TestIvalidIP(t *testing.T) {
func TestInvalidIP(t *testing.T) {
req, _ := http.NewRequest("GET", "/", nil)
req.Header.Add("X-Real-IP", "100.100.100.1000")
w := httptest.NewRecorder()
8 changes: 4 additions & 4 deletions middleware/recoverer_test.go
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import (
"github.com/go-chi/chi/v5"
)

func panicingHandler(http.ResponseWriter, *http.Request) { panic("foo") }
func panickingHandler(http.ResponseWriter, *http.Request) { panic("foo") }

func TestRecoverer(t *testing.T) {
r := chi.NewRouter()
@@ -21,7 +21,7 @@ func TestRecoverer(t *testing.T) {
recovererErrorWriter = buf

r.Use(Recoverer)
r.Get("/", panicingHandler)
r.Get("/", panickingHandler)

ts := httptest.NewServer(r)
defer ts.Close()
@@ -32,8 +32,8 @@ func TestRecoverer(t *testing.T) {
lines := strings.Split(buf.String(), "\n")
for _, line := range lines {
if strings.HasPrefix(strings.TrimSpace(line), "->") {
if !strings.Contains(line, "panicingHandler") {
t.Fatalf("First func call line should refer to panicingHandler, but actual line:\n%v\n", line)
if !strings.Contains(line, "panickingHandler") {
t.Fatalf("First func call line should refer to panickingHandler, but actual line:\n%v\n", line)
}
return
}