```
type MiddlewareFunc func(HandlerFunc) HandlerFunc type HandlerFunc func() error func applyMiddleware(h HandlerFunc, middleware MiddlewareFunc) HandlerFunc { h = middleware(h) return h } func main() { h := func() error { time.Sleep(3 * time.Second) fmt.Println("H") return nil } n := func(next HandlerFunc) HandlerFunc { return func() error { start := time.Now() if err := next(); err != nil { return err } cost := time.Now().Sub(start) fmt.Println(cost) return nil } } hh := applyMiddleware(h, n) if err := hh(); err != nil { fmt.Println(err) } } ```