title: How to call localhost Handler efficiently with Go Gin? And how to get the running url?
body: <p>I reach a situation that inside a Go Gin Handler, I need to call another handler.</p>
  <p>I figured that composing a new gin.Context object is hard, so it maybe easier just make a request to localhost, which going through the router although it is not necessary.</p>
  <p>So is there a more efficient method that I can call directly another handler?</p>
  <p>However it comes to that how to get the running URL ? Of course it can be hard coded since it is known, but is there a function like below?</p>
  <pre><code>ts := httptest.NewServer(GetMainEngine())
  defer ts.Close()
  
  log.Println(GetJWTMiddleware())
  // here ts.URL is the running url in test
  req, _ := http.NewRequest(&quot;POST&quot;, ts.URL + &quot;/u/login&quot;, bytes.NewBuffer(loginPostString))
  </code></pre>
  <p>How to get the <code>ts.URL</code> with just gin?</p>