code: func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
  	// panic handler
  	defer func() {
  		if err := recover(); err != nil {
  			log.Printf("panic: %s", err)
  			if r.PanicHandler != nil {
  				r.PanicHandler(w, req)
  			} else {
  				http.Error(w, http.StatusText(500), http.StatusInternalServerError)
  			}
  		}
  	}()
  
  	// Request-ID
  	var rid string
  	if r.RequestID != "" {
  		if rid = req.Header.Get(r.RequestID); rid != "" {
  			w.Header().Set(r.RequestID, rid)
  		}
  	}
  
  	// wrap ResponseWriter
  	var ww *ResponseWriter
  	if r.LogRequests {
  		ww = NewResponseWriter(w, rid)
  	}
  
  	// set version based on the value of "Accept: application/vnd.*"
  	version := req.Header.Get("Accept")
  	if i := strings.LastIndex(version, versionHeader); i != -1 {
  		version = version[len(versionHeader)+i:]
  	} else {
  		version = ""
  	}
  
  	// query the path from left to right
  	node, key, path, leaf := r.routes.Get(req.URL.Path, version)
  
  	// dispatch the request
  	h, p := r.dispatch(node, key, path, req.Method, version, leaf, nil)
  
  	// dispatch request
  	if r.LogRequests {
  		if p == nil {
  			h.ServeHTTP(ww, req)
  		} else {
  			h.ServeHTTP(ww, req.WithContext(context.WithValue(req.Context(), ParamsKey, p)))
  		}
  		r.Logger(ww, req)
  	} else {
  		if p == nil {
  			h.ServeHTTP(w, req)
  		} else {
  			h.ServeHTTP(w, req.WithContext(context.WithValue(req.Context(), ParamsKey, p)))
  		}
  	}
  }
docs: // ServeHTTP dispatches the handler registered in the matched path