Skip to content

Commit

Permalink
Fix typos in comments and variable names (#849)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear authored Oct 18, 2023
1 parent 779d661 commit 355dd04
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
2 changes: 1 addition & 1 deletion _examples/versions/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions middleware/compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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")

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion middleware/realip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions middleware/recoverer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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
}
Expand Down

0 comments on commit 355dd04

Please sign in to comment.