add realip, requestlog, recoverer middlewares
Initial implementation of lightmux-contrib, a sibling module to lightmux that hosts opinionated middlewares with one sub-package per middleware: - realip: resolves the originating client IP from CF-Connecting-IP, True-Client-IP, X-Real-IP, or X-Forwarded-For. Optional peer-CIDR allowlist via netip.Prefix. - requestlog: emits a structured http.request record (method, path, status, duration, client) per request via splinter. - recoverer: catches panics, wraps with errx under op "recoverer", logs with stack, and writes a 500 response. Each package exposes a single New(...) constructor returning func(http.Handler) http.Handler. The contrib module intentionally does not import lightmux — middlewares interoperate via the standard stdlib middleware shape. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
9dc0fc5d26
commit
b26ef7439e
10 changed files with 624 additions and 0 deletions
43
Taskfile.yml
Normal file
43
Taskfile.yml
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
version: '3'
|
||||
|
||||
tasks:
|
||||
default:
|
||||
desc: Run vet and tests
|
||||
cmds:
|
||||
- task: check
|
||||
|
||||
install:tools:
|
||||
desc: Install development tools (tparse for prettier test output)
|
||||
cmds:
|
||||
- go install github.com/mfridman/tparse@latest
|
||||
|
||||
test:
|
||||
desc: Run tests with prettier output via tparse
|
||||
cmds:
|
||||
- set -o pipefail && go test ./... -json -cover | tparse -all
|
||||
|
||||
test:race:
|
||||
desc: Run tests under the race detector
|
||||
cmds:
|
||||
- set -o pipefail && go test ./... -race -json | tparse -all
|
||||
|
||||
vet:
|
||||
desc: Run go vet
|
||||
cmds:
|
||||
- go vet ./...
|
||||
|
||||
fmt:
|
||||
desc: Format Go source files
|
||||
cmds:
|
||||
- gofmt -w .
|
||||
|
||||
tidy:
|
||||
desc: Tidy go.mod
|
||||
cmds:
|
||||
- go mod tidy
|
||||
|
||||
check:
|
||||
desc: Run vet and tests
|
||||
cmds:
|
||||
- task: vet
|
||||
- task: test
|
||||
Loading…
Add table
Add a link
Reference in a new issue