Send

Sets the HTTP response body. The Send body can be of any type.

Send doesn’t append like the Write method.
  1. c.Send(body ...interface{})
  1. app.Get("/", func(c *fiber.Ctx) {
  2. c.Send("Hello, World!") // => "Hello, World!"
  3. c.Send([]byte("Hello, World!")) // => "Hello, World!"
  4. c.Send(123) // => 123
  5. })

Fiber also provides SendBytes & SendString methods for raw inputs.

Use this, if you don’t need type assertion, recommended for faster performance.
  1. c.SendBytes(b []byte)
  2. c.SendString(s string)
  1. app.Get("/", func(c *fiber.Ctx) {
  2. c.SendByte([]byte("Hello, World!"))
  3. // => "Hello, World!"
  4.  
  5. c.SendString("Hello, World!")
  6. // => "Hello, World!"
  7. })