title: Where does the serveHTTP utility come from on supposedly naked func
body: <p>I have this utility:</p>
  
  <pre><code>type Handler struct{}
  
  func (h Handler) Mount(router *mux.Router, v PeopleInjection) {
      router.HandleFunc("/api/v1/people", h.makeGetMany(v)).Methods("GET")
  }
  </code></pre>
  
  <p>the above calls this:</p>
  
  <pre><code>func (h Handler) makeGetMany(v PeopleInjection) http.HandlerFunc {
  
      type RespBody struct {}
  
      type ReqBody struct {
          Handle string
      }
  
      return tc.ExtractType(
          tc.TypeList{ReqBody{},RespBody{}},
          func(w http.ResponseWriter, r *http.Request) {
           // ...
      })
  }
  </code></pre>
  
  <p>and then <code>tc.ExtractType</code> is like so:</p>
  
  <pre><code>func ExtractType(s TypeList, h http.HandlerFunc) http.HandlerFunc {
  
      return func(w http.ResponseWriter, r *http.Request) {
  
          h.ServeHTTP(w, r)  // &lt;&lt;&lt; h is just a func right? so where does ServeHTTP come from?
      }
  }
  </code></pre>
  
  <p>my question is - where does the serveHTTP method/func come from??</p>
  
  <p>isn't the <code>h</code> parameter just a func with this signature:</p>
  
  <pre><code>func(w http.ResponseWriter, r *http.Request) { ... }
  </code></pre>
  
  <p>so then how does that func have the <code>ServeHTTP</code> func attached to it?</p>
  
  <p>In other words, why I am I calling</p>
  
  <pre><code>h.ServeHTTP(w,r)
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>h(w,r)
  </code></pre>
  
  <p>?</p>