AGENTS.md: no direct commits to main, all changes via feature branches

This commit is contained in:
clawbot
2026-02-09 12:31:14 -08:00
parent e9b6eb862e
commit 7b0ff178d4
14 changed files with 247 additions and 100 deletions

View File

@@ -1,3 +1,4 @@
// Package handlers provides HTTP request handlers for the chat server.
package handlers
import (
@@ -13,36 +14,43 @@ import (
"go.uber.org/fx"
)
// HandlersParams defines the dependencies for creating Handlers.
type HandlersParams struct {
fx.In
Logger *logger.Logger
Globals *globals.Globals
Database *db.Database
Healthcheck *healthcheck.Healthcheck
}
// Handlers manages HTTP request handling.
type Handlers struct {
params *HandlersParams
log *slog.Logger
hc *healthcheck.Healthcheck
}
// New creates a new Handlers instance.
func New(lc fx.Lifecycle, params HandlersParams) (*Handlers, error) {
s := new(Handlers)
s.params = &params
s.log = params.Logger.Get()
s.hc = params.Healthcheck
lc.Append(fx.Hook{
OnStart: func(ctx context.Context) error {
OnStart: func(_ context.Context) error {
return nil
},
})
return s, nil
}
func (s *Handlers) respondJSON(w http.ResponseWriter, r *http.Request, data interface{}, status int) {
func (s *Handlers) respondJSON(w http.ResponseWriter, _ *http.Request, data interface{}, status int) {
w.WriteHeader(status)
w.Header().Set("Content-Type", "application/json")
if data != nil {
err := json.NewEncoder(w).Encode(data)
if err != nil {
@@ -51,6 +59,6 @@ func (s *Handlers) respondJSON(w http.ResponseWriter, r *http.Request, data inte
}
}
func (s *Handlers) decodeJSON(w http.ResponseWriter, r *http.Request, v interface{}) error {
func (s *Handlers) decodeJSON(_ http.ResponseWriter, r *http.Request, v interface{}) error {
return json.NewDecoder(r.Body).Decode(v)
}