Send

Sets the HTTP response body.

  1. func (c *Ctx) Send(body []byte) error
  1. app.Get("/", func(c *fiber.Ctx) error {
  2. return c.Send([]byte("Hello, World!")) // => "Hello, World!"
  3. })

Fiber also provides SendString and SendStream methods for raw inputs.

Use this if you don’t need type assertion, recommended for faster performance.
  1. func (c *Ctx) SendString(body string) error
  2. func (c *Ctx) SendStream(stream io.Reader, size ...int) error
  1. app.Get("/", func(c *fiber.Ctx) error {
  2. return c.SendString("Hello, World!")
  3. // => "Hello, World!"
  4. return c.SendStream(bytes.NewReader([]byte("Hello, World!")))
  5. // => "Hello, World!"
  6. })