title: Is it OK to use the chain of http.HandlerFunc?
body: <p>Using Go http package for a while, I found a convenient way to split responsibilities of the target (endpoint) of HTTP request, over several chain call of http.HandlerFunc:</p>
  
  <pre><code>func HeaderValidator(h func(http.ResponseWriter, *HttpRequest)) http.HandlerFunc {
      return func(w http.ResponseWriter, req *HttpRequest) {
          ...
          h(w, req)
      }
  }
  </code></pre>
  
  <p>So now, the handler looks like:</p>
  
  <pre><code>router.HandleFunc("/", handler.Log(handler.HeaderValidator(handler.RequestTimer(handler.TargetHandler))))
  </code></pre>
  
  <p>I guess this is not so good from an efficiency point of view (at least, it requires a stack allocation for a functions call) as well as code readability hurts a bit.</p>
  
  <p>Is there a more graceful and efficient way to do that?</p>