title: in tests mux.Vars() returns nil instead of expected map
body: <p>I have a Gorilla Mux router setup inside a function that returns <code>*mux.Router</code>, goes like this</p>
  <pre><code>func MakeApp(services service.Service, pe PolicyEnforce) *mux.Router {
      app := mux.NewRouter()
  
      app.NotFoundHandler = &amp;NotFound{}
  
      app.Use(token.TokenMiddleware)
  
      # ...
      
      app.Methods(http.MethodPost).Path(&quot;/api/v1/subscription/{emisor}/mh&quot;).HandlerFunc(MakeUpdateMH(services, pe))
      app.Methods(http.MethodGet).Path(&quot;/api/v1/subscription/{emisor}/mh&quot;).HandlerFunc(MakeGetMH(services, pe))
      app.Methods(http.MethodPost).Path(&quot;/api/v1/subscription&quot;).HandlerFunc(MakeCreateSubscription(services, pe))
      app.Methods(http.MethodGet).Path(&quot;/api/v1/subscription/{emisor}&quot;).HandlerFunc(MakeGetSubscription(services, pe))
      
      # ...
  
      return app
  }
  </code></pre>
  <p>So, on my tests I prepare the handle with an URL and run it:</p>
  <pre><code>func (suite *AppTestSuite) TestUpdateMH() {
      args := &amp;service.UpdateMHInput{
          Usuario:     new(string),
          Clave:       new(string),
          Pin:         new(string),
          Certificado: new(string),
          Actividades: []string{},
      }
      reader, err := makeBody(args)
      suite.NoError(err)
  
      handle := token.TokenMiddleware(transport.MakeUpdateMH(suite._s, suite.pe))
  
      req := httptest.NewRequest(http.MethodPut, &quot;/api/v1/subscription/-/mh&quot;, reader)
      w := httptest.NewRecorder()
  
      t := genToken([]v43.Rol{
          {
              Nombre: &quot;mh&quot;,
              Permisos: []v43.Permiso{{
                  Sujeto: permission.MHCredentials,
                  Accion: permission.Update,
              }},
          },
      })
      req.Header.Add(&quot;Authorization&quot;, t)
  
      // configura repository
      suite.r.On(&quot;UpdateIssuerMH&quot;, emisor, args.Usuario, args.Clave, args.Pin, args.Certificado, args.Actividades).Return(v43.Grupo{}, nil)
      handle.ServeHTTP(w, req)
  
      resp := w.Result()
  
      suite.Equal(http.StatusOK, resp.StatusCode, resp.Status)
  }
  </code></pre>
  <p>Inside the handle things look like this:</p>
  <pre><code>func MakeUpdateMH(s service.Service, p PolicyEnforce) http.HandlerFunc {
      return func(w http.ResponseWriter, r *http.Request) {
          emisor := mux.Vars(r)[&quot;emisor&quot;]
  
          // revisa permisos
          permitido := p.TienePermiso(r.Context(), permission.MHCredentials, permission.Update) &amp;&amp; p.PuedeActuarSobreEmisor(r.Context(), emisor)
          if !permitido {
              reportError(w, fault.ErrPermissionDenied, http.StatusForbidden, fault.MessageForbidden, fault.MessageForbidden)
              return
          }
          // cambia el emisor afectado por aquel obtenido de la URL
          if emisor != &quot;-&quot; || emisor == &quot;&quot; {
              emisor = token.GetSub(r.Context())
          }
  
          var input service.UpdateMHInput
          dec := json.NewDecoder(r.Body)
          err := dec.Decode(&amp;input)
          if err != nil {
              http.Error(w, fault.NewBackendError(&quot;no se pudo decodificar solicitud: %v&quot;, err).Error(), http.StatusBadRequest)
              return
          }
  
          output, err := s.UpdateMHCredentials(emisor, input.Usuario, input.Clave, input.Pin, input.Certificado, input.Actividades)
          if err != nil {
              http.Error(w, fault.NewBackendError(&quot;Error al actualizar credenciales de MH: %v&quot;, err).Error(), http.StatusInternalServerError)
              return
          }
  
          enc := json.NewEncoder(w)
          enc.Encode(output)
      }
  }
  </code></pre>
  <p>and I've noticed that <code>mux.Vars(r)</code> is returning <code>nil</code> instead of the map of values, which should contain <code>{&quot;emisor&quot;: &quot;-&quot;}</code> and I cannot understand why this is not the case.</p>
  <p>I'm already handling the case for when <code>&quot;emisor&quot;</code> is empty, but for other routers where &quot;-&quot; or empty string cannot be used this quirk is causing me troubles, <strong>what am I doing wrong, and how can I still run my tests successfully without having to manually inject my Vars?</strong> and also: <strong>will this issue translate into production?</strong></p>