Skip to content

Commit

Permalink
feat(net/http): add HandlerDecoratorFunc
Browse files Browse the repository at this point in the history
  • Loading branch information
searKing committed Oct 9, 2024
1 parent f6f6be5 commit 865fae9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions go/net/http/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ type HandlerDecorator interface {
WrapHandler(rt http.Handler) http.Handler
}

// The HandlerDecoratorFunc type is an adapter to allow the use of
// ordinary functions as HTTP handler decorators. If f is a function
// with the appropriate signature, HandlerDecoratorFunc(f) is a
// [HandlerDecorator] that calls f.
type HandlerDecoratorFunc func(rt http.Handler) http.Handler

// WrapHandler calls f(rt).
func (f HandlerDecoratorFunc) WrapHandler(rt http.Handler) http.Handler {
return f(rt)
}

// HandlerDecorators defines a HandlerDecorator slice.
type HandlerDecorators []HandlerDecorator

Expand Down

0 comments on commit 865fae9

Please sign in to comment.