SendFile

Transfers the file from the given path. Sets the Content-Type response HTTP header field based on the filenames extension.

Method use gzipping by default, set it to true to disable.
  1. c.SendFile(path string, compress ...bool) error
  1. app.Get("/not-found", func(c *fiber.Ctx) {
  2. if err := c.SendFile("./public/404.html"); err != nil {
  3. c.Next(err) // pass err to ErrorHandler
  4. }
  5. // Enable compression
  6. if err := c.SendFile("./static/index.html", true); err != nil {
  7. c.Next(err) // pass err to ErrorHandler
  8. }
  9. })