Send
Sets the HTTP response body. The Send body can be of any type.
Send doesn’t append like the Write method.
c.Send(body ...interface{})
app.Get("/", func(c *fiber.Ctx) {
c.Send("Hello, World!") // => "Hello, World!"
c.Send([]byte("Hello, World!")) // => "Hello, World!"
c.Send(123) // => 123
})
Fiber also provides SendBytes
,SendString
and SendStream
methods for raw inputs.
c.SendBytes(b []byte)
c.SendString(s string)
c.SendStream(r io.Reader, s ...int)
app.Get("/", func(c *fiber.Ctx) {
c.SendByte([]byte("Hello, World!"))
// => "Hello, World!"
c.SendString("Hello, World!")
// => "Hello, World!"
c.SendStream(bytes.NewReader([]byte("Hello, World!")))
// => "Hello, World!"
})