Format
Performs content-negotiation on the Accept HTTP header. It uses Accepts to select a proper format.
If the header is not specified or there is no proper format, text/plain is used.
- c.Format(body interface{})
- app.Get("/", func(c *fiber.Ctx) {
- // Accept: text/plain
- c.Format("Hello, World!")
- // => Hello, World!
- // Accept: text/html
- c.Format("Hello, World!")
- // => <p>Hello, World!</p>
- // Accept: application/json
- c.Format("Hello, World!")
- // => "Hello, World!"
- })