From fe0f0852da163778bdb33b357cc7264e46176fc0 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Tue, 19 Sep 2023 20:07:02 +0300 Subject: [PATCH] Fix typos in comments and variable names --- CHANGELOG.md | 2 +- _examples/versions/main.go | 2 +- context.go | 2 +- middleware/compress.go | 14 +++++++------- middleware/realip_test.go | 2 +- middleware/recoverer_test.go | 8 ++++---- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6eb7e6e..66bccc36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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`, diff --git a/_examples/versions/main.go b/_examples/versions/main.go index 7fc6c90e..3bd019a0 100644 --- a/_examples/versions/main.go +++ b/_examples/versions/main.go @@ -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)) diff --git a/context.go b/context.go index 88f8e221..0eda1a24 100644 --- a/context.go +++ b/context.go @@ -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 diff --git a/middleware/compress.go b/middleware/compress.go index 773d47a1..5945c503 100644 --- a/middleware/compress.go +++ b/middleware/compress.go @@ -201,7 +201,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 @@ -275,10 +275,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 { @@ -310,13 +310,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") @@ -334,7 +334,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 diff --git a/middleware/realip_test.go b/middleware/realip_test.go index 9cbc1c49..1ab5e95e 100644 --- a/middleware/realip_test.go +++ b/middleware/realip_test.go @@ -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() diff --git a/middleware/recoverer_test.go b/middleware/recoverer_test.go index 15e8ae58..e50f47cd 100644 --- a/middleware/recoverer_test.go +++ b/middleware/recoverer_test.go @@ -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 }