title: How to serve file from go embed
body: <p>I have a static directory, containing a <code>sign.html</code> file :</p>
  <pre><code>//go:embed static
  var static embed.FS
  </code></pre>
  <p>It is served that way and works fine :</p>
  <pre><code>fSys, err := fs.Sub(static, &quot;static&quot;)
  if err != nil {
      return err
  }
  mux.Handle(&quot;/&quot;, http.FileServer(http.FS(fSys)))
  </code></pre>
  <p>On some routes though (for instance: <code>/sign</code>), I want to do some checks before serving the page. This is my handler :</p>
  <pre><code>func (h Handler) ServeSignPage(w http.ResponseWriter, r *http.Request) error {
      publicKey := r.URL.Query().Get(&quot;publicKey&quot;)
      err := h.Service.AuthorizeClientSigning(r.Context(), publicKey)
      if err != nil {
          return err
      }
      // this is where I'd like to serve the embed file
      // sign.html from the static directory
      http.ServeFile(w, r, &quot;sign.html&quot;)
      return nil
  }
  </code></pre>
  <p>Unfortunately, the <code>ServeFile</code> displays not found. How can I serve the file from the file server within that <code>ServeSignPage</code> ?</p>