Add HEAD method support to Ping middleware#42
Conversation
- Ping middleware now handles both GET and HEAD methods for /ping endpoint
- HEAD returns 200 OK with headers but no body (useful for lightweight health checks)
- Update dependencies: golang.org/x/crypto 0.45.0 -> 0.46.0, golang.org/x/sys 0.38.0 -> 0.39.0
- Apply modernize linter fixes:
- Replace interface{} with any
- Use max() builtin instead of if/else
- Use strings.SplitSeq for more efficient iteration
Pull Request Test Coverage Report for Build 20806401957Details
💛 - Coveralls |
There was a problem hiding this comment.
Pull request overview
This pull request adds HEAD method support to the Ping middleware for lightweight health checks and includes dependency updates and linter-driven modernization fixes.
Key changes:
- Ping middleware now accepts HEAD requests in addition to GET, returning status and headers without a body
- Modernization: replaced
interface{}withanyalias throughout the codebase - Applied modern Go idioms:
max()builtin andstrings.SplitSeqiterator pattern
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| middleware.go | Added HEAD method support to Ping middleware with proper documentation |
| middleware_test.go | Refactored tests into subtests covering GET, HEAD, POST, and other paths |
| rest.go | Replaced interface{} with any in function signatures |
| logger/logger.go | Replaced interface{} with any in Backend interface and implementation |
| gzip.go | Replaced interface{} with any in sync.Pool definition |
| benchmarks.go | Modernized interval calculation using max() builtin |
| realip/real.go | Attempted to use strings.SplitSeq for iteration |
| go.mod | Updated golang.org/x/crypto from v0.45.0 to v0.46.0 and golang.org/x/sys from v0.38.0 to v0.39.0 |
| go.sum | Updated checksums for dependency updates |
| .golangci.yml | Added modernize and testifylint linters |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if xff := r.Header.Get("X-Forwarded-For"); xff != "" { | ||
| addresses := strings.Split(xff, ",") | ||
| for _, addr := range addresses { | ||
| for addr := range strings.SplitSeq(xff, ",") { |
There was a problem hiding this comment.
The function strings.SplitSeq does not exist in the Go standard library. The standard function is strings.Split which returns a slice of strings. If you intended to use an iterator-based approach available in Go 1.23+, you would need strings.Fields or similar, but strings.SplitSeq is not a valid function name. This change will cause a compilation error.
| for addr := range strings.SplitSeq(xff, ",") { | |
| for _, addr := range strings.Split(xff, ",") { |
Ping middleware now handles both GET and HEAD methods for the /ping endpoint. HEAD returns 200 OK with headers but no body, which is useful for lightweight health checks by monitoring tools.
Changes:
Also includes:
interface{}→any,max()builtin,strings.SplitSeq