Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decorate ¶
Decorate decorates the http.Handler with a list of Decorators and returns the decorated http.Handler. Each of the decorators pasted in is a func that takes an http.Hanlder and returns an http.Handler. The idea is to chain the http.Handler h with the decorators so that the decorator funcion is called before h. The Decorators are left associative. The order of the decorators are called as the following (from right / last to the left / first):
h := Decorate(hdl, d3, d2, d1) //same as // h:= d1(d2(d3(hdl))) before d1 before d2 before d3 HandlerFunc after d3 after d2 after d1
Refer to decorator_test for addtional info.
Types ¶
type Decorator ¶
Decordator is a func that takes an http.Handler and returns an http.Handler. Refer to decorator_test for details of the use cases.
type DecoratorChain ¶
type DecoratorChain []Decorator
DecoratorChain is an array of Decorators.
func Chain ¶
func Chain(decorators ...Decorator) DecoratorChain
Chain chains the Decorators into an array. DecorateChain may be re-used to decorate different http.Handler.
func (DecoratorChain) Append ¶
func (dc DecoratorChain) Append(decorators ...Decorator) DecoratorChain
Append additional Decorators to the given DecoratorChain.
func (DecoratorChain) Decorate ¶
func (dc DecoratorChain) Decorate(h ghttp.Handler) ghttp.Handler
Decorate decortoes an http.Handler with the given DecoratorChain and returns the decorated http Handler.
func (DecoratorChain) DecorateRouter ¶
func (dc DecoratorChain) DecorateRouter(r ghttp.Router) ghttp.Router
DecorateRouter decorates each http.Handler in the router with the given DecoratorChain and returns the decorated router.