title: How to Use Specific middleware for specific routes in a Get Subrouter in gorilla mux
body: <p>I have a specific requirement with Gorilla mux routing where i want to add different Middlewares for different routes that are under one subrouter( GET subrouter in my case). Below is my code for routing:</p>
  <pre><code>    // create a serve mux
      sm := mux.NewRouter()
  
      // register handlers
      postR := sm.Methods(http.MethodPost).Subrouter()
      postR.HandleFunc(&quot;/signup&quot;, uh.Signup)
      postR.HandleFunc(&quot;/login&quot;, uh.Login)
      postR.Use(uh.MiddlewareValidateUser)
  
      getR := sm.Methods(http.MethodGet).Subrouter()
      getR.HandleFunc(&quot;/refresh-token&quot;, uh.RefreshToken)
      getR.HandleFunc(&quot;/user-profile&quot;, uh.GetUserProfile)
  </code></pre>
  <p>In the above router logic both my /refresh-token and /user-profile token come under getR router. Also i have two middleware functions called ValidateAccessToken and ValidateRefreshToken. I want to use the ValidateRefreshToken middleware function for &quot;/refresh-token&quot; route and ValidateAccessToken for all other routes under GET subrouter. I want to do it with Gorilla mux routing itself. Please suggest me the appropriate approach to accomplish the above scenario. Thanks for your time and effort.</p>