Help us shape the future of Go! Take the 2026 Go Developer Survey

middleware

command
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Command middleware shows how to wrap a Handler[T] with taskQ middleware: structured logging, a hand-written recorder, and panic recovery — composed with taskq.Chain and run by the built-in taskq.Pool.

Middleware order matters. taskq.Chain(base, A, B, C) runs as A(B(C(base))): the first listed is outermost — it sees the task first and the returned error last. Per the package docs, RecoveryMiddleware goes LAST (innermost, directly wrapping the handler) so the *PanicError it produces is visible to the middleware listed before it — here, the recorder and the logger.

Run it with:

go run ./examples/membroker/middleware

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL