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 and SendStream 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)
  3. c.SendStream(r io.Reader, s ...int)
  1. app.Get("/", func(c *fiber.Ctx) {
  2. c.SendByte([]byte("Hello, World!"))
  3. // => "Hello, World!"
  4. c.SendString("Hello, World!")
  5. // => "Hello, World!"
  6. c.SendStream(bytes.NewReader([]byte("Hello, World!")))
  7. // => "Hello, World!"
  8. })