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:
@@ -14,8 +14,8 @@ import (
|
||||
"go.uber.org/fx"
|
||||
)
|
||||
|
||||
// HandlersParams defines the dependencies for creating Handlers.
|
||||
type HandlersParams struct {
|
||||
// Params defines the dependencies for creating Handlers.
|
||||
type Params struct {
|
||||
fx.In
|
||||
|
||||
Logger *logger.Logger
|
||||
@@ -26,13 +26,13 @@ type HandlersParams struct {
|
||||
|
||||
// Handlers manages HTTP request handling.
|
||||
type Handlers struct {
|
||||
params *HandlersParams
|
||||
params *Params
|
||||
log *slog.Logger
|
||||
hc *healthcheck.Healthcheck
|
||||
}
|
||||
|
||||
// New creates a new Handlers instance.
|
||||
func New(lc fx.Lifecycle, params HandlersParams) (*Handlers, error) {
|
||||
func New(lc fx.Lifecycle, params Params) (*Handlers, error) {
|
||||
s := new(Handlers)
|
||||
s.params = ¶ms
|
||||
s.log = params.Logger.Get()
|
||||
@@ -47,7 +47,7 @@ func New(lc fx.Lifecycle, params HandlersParams) (*Handlers, error) {
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func (s *Handlers) respondJSON(w http.ResponseWriter, _ *http.Request, data interface{}, status int) {
|
||||
func (s *Handlers) respondJSON(w http.ResponseWriter, _ *http.Request, data any, status int) {
|
||||
w.WriteHeader(status)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
@@ -58,7 +58,3 @@ func (s *Handlers) respondJSON(w http.ResponseWriter, _ *http.Request, data inte
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Handlers) decodeJSON(_ http.ResponseWriter, r *http.Request, v interface{}) error {
|
||||
return json.NewDecoder(r.Body).Decode(v)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user