Documentation
¶
Index ¶
- func ContextValueMiddleware(key ContextKey, val interface{}) func(http.Handler) http.Handler
- func ExtractLogger(ctx context.Context) *slog.Logger
- func ExtractRequestID(ctx context.Context) string
- func InjectLogger(logger *slog.Logger) func(http.Handler) http.Handler
- func InjectRequestID(next http.Handler) http.Handler
- func Recoverer(next http.Handler) http.Handler
- func RequestLogger(next http.Handler) http.Handler
- func UpdateLogger(r *http.Request, logger *slog.Logger) *http.Request
- type Chain
- type Constructor
- type ContextKey
- type WrapResponseWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextValueMiddleware ¶
func ContextValueMiddleware(key ContextKey, val interface{}) func(http.Handler) http.Handler
ContextValueMiddleware is a convenience function which stores a static value in the request context using the given contextKey.
func ExtractRequestID ¶
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
func NewChain ¶
func NewChain(middlewares ...Constructor) Chain
type ContextKey ¶
type ContextKey string
const CurrentUserContextKey ContextKey = "CurrentUser"
func (ContextKey) String ¶
func (c ContextKey) String() string
type WrapResponseWriter ¶
type WrapResponseWriter interface {
http.ResponseWriter
// Status returns the HTTP status of the request, or 0 if one has not
// yet been sent.
Status() int
// BytesWritten returns the total number of bytes sent to the client.
BytesWritten() int
// Unwrap returns the original proxied target.
Unwrap() http.ResponseWriter
}
WrapResponseWriter is a proxy around an http.ResponseWriter that allows you to hook into various parts of the response process.
func NewWrapResponseWriter ¶
func NewWrapResponseWriter(w http.ResponseWriter, protoMajor int) WrapResponseWriter
NewWrapResponseWriter wraps an http.ResponseWriter, returning a proxy that allows you to introspect various information about the response.
Click to show internal directories.
Click to hide internal directories.