title: How to render static files within Gin router?
body: <p>I want to serve a JSON file with gin server. And set some customize values in the HTML file. Use JavaScript in it to call the JSON file.</p>
  <p>My application structure:</p>
  <pre><code>.
  ├── main.go
  └── templates
      ├── index.html
      └── web.json
  </code></pre>
  <p>I put these basic source into <code>main.go</code> file:</p>
  <pre><code>package main
  
  import (
      &quot;net/http&quot;
  
      &quot;github.com/gin-gonic/gin&quot;
  )
  
  var router *gin.Engine
  
  func main() {
      router = gin.Default()
      router.LoadHTMLGlob(&quot;templates/*&quot;)
  
      router.GET(&quot;/web&quot;, func(c *gin.Context) {
          c.HTML(
              http.StatusOK,
              &quot;index.html&quot;,
              gin.H{
                  &quot;title&quot;: &quot;Web&quot;,
                  &quot;url&quot;:   &quot;./web.json&quot;,
              },
          )
      })
  
      router.Run()
  }
  </code></pre>
  <p>Some code in <code>templates/index.html</code> file:</p>
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  
    &lt;head&gt;
      &lt;title&gt;{{ .title }}&lt;/title&gt;
  
      // ...
    &lt;/head&gt;
  
    &lt;body&gt;
      &lt;div id=&quot;swagger-ui&quot;&gt;&lt;/div&gt;
  
      // ...
      
      &lt;script&gt;
        window.onload = function() {
          // Begin Swagger UI call region
          const ui = SwaggerUIBundle({
            url: &quot;{{ .url }}&quot;,
            dom_id: '#swagger-ui',
            // ...
          })
          // End Swagger UI call region
  
          window.ui = ui
        }
      &lt;/script&gt;
  
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>When running the application, I got a fetch error:</p>
  <blockquote>
  <p>Not Found ./web.json</p>
  </blockquote>
  <p>So how should I serve the <code>web.json</code> file to be accessed in the Gin internal server?</p>