Documentation
¶
Overview ¶
Package httpmw provides stdlib net/http middleware for transport concerns: panic recovery, CORS, request ID injection, and structured request logging.
No authentication or identity logic lives here — see httpauth-firebase for that.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CORS ¶
CORS applies Cross-Origin Resource Sharing headers. origins is the allowed origins list. Pass []string{"*"} for development.
Types ¶
type Logger ¶
type Logger interface {
Info(msg string, args ...any)
Error(msg string, err error, args ...any)
With(args ...any) Logger
}
Logger is the minimal interface httpmw needs — satisfied by logz.Logger via duck typing. httpmw does NOT duck-type the Logger for context purposes (it imports logz for logz.WithRequestID / logz.GetRequestID context helpers).
type StatusRecorder ¶
type StatusRecorder struct {
http.ResponseWriter
Status int
}
StatusRecorder wraps http.ResponseWriter to expose the written status code.
func (*StatusRecorder) WriteHeader ¶
func (r *StatusRecorder) WriteHeader(code int)