Fix all lint issues and update AGENTS.md workflow rules
- Fix stuttering type names (e.g. config.ConfigParams → config.Params) - Add doc comments to all exported types/functions/methods - Add package doc comments to all packages - Fix JSON tags to camelCase - Extract magic numbers to constants - Add blank lines per nlreturn/wsl_v5 rules - Use errors.Is() for error comparison - Unexport NewLoggingResponseWriter (not used externally) - Replace for-range on ctx.Done() with channel receive - Rename unused parameters to _ - AGENTS.md: all changes via feature branches, no direct main commits
This commit is contained in:
@@ -22,8 +22,8 @@ import (
|
||||
|
||||
const corsMaxAge = 300
|
||||
|
||||
// MiddlewareParams defines the dependencies for creating Middleware.
|
||||
type MiddlewareParams struct {
|
||||
// Params defines the dependencies for creating Middleware.
|
||||
type Params struct {
|
||||
fx.In
|
||||
|
||||
Logger *logger.Logger
|
||||
@@ -34,11 +34,11 @@ type MiddlewareParams struct {
|
||||
// Middleware provides HTTP middleware handlers.
|
||||
type Middleware struct {
|
||||
log *slog.Logger
|
||||
params *MiddlewareParams
|
||||
params *Params
|
||||
}
|
||||
|
||||
// New creates a new Middleware instance.
|
||||
func New(_ fx.Lifecycle, params MiddlewareParams) (*Middleware, error) {
|
||||
func New(_ fx.Lifecycle, params Params) (*Middleware, error) {
|
||||
s := new(Middleware)
|
||||
s.params = ¶ms
|
||||
s.log = params.Logger.Get()
|
||||
@@ -65,8 +65,8 @@ type loggingResponseWriter struct {
|
||||
statusCode int
|
||||
}
|
||||
|
||||
// NewLoggingResponseWriter wraps a ResponseWriter to capture the status code.
|
||||
func NewLoggingResponseWriter(w http.ResponseWriter) *loggingResponseWriter {
|
||||
// newLoggingResponseWriter wraps a ResponseWriter to capture the status code.
|
||||
func newLoggingResponseWriter(w http.ResponseWriter) *loggingResponseWriter {
|
||||
return &loggingResponseWriter{w, http.StatusOK}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ func (s *Middleware) Logging() func(http.Handler) http.Handler {
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
start := time.Now()
|
||||
lrw := NewLoggingResponseWriter(w)
|
||||
lrw := newLoggingResponseWriter(w)
|
||||
ctx := r.Context()
|
||||
|
||||
defer func() {
|
||||
|
||||
Reference in New Issue
Block a user