mirror of
https://github.com/makayabou/asg-server.git
synced 2026-05-02 17:43:36 +02:00
24 lines
410 B
Go
24 lines
410 B
Go
package jsonify
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
func New() fiber.Handler {
|
|
return func(c *fiber.Ctx) error {
|
|
if err := c.Next(); err != nil {
|
|
return err
|
|
}
|
|
|
|
contentType := string(c.Response().Header.ContentType())
|
|
if strings.Contains(contentType, "application/json") {
|
|
return nil
|
|
}
|
|
|
|
body := c.Response().Body()
|
|
return c.JSON(fiber.Map{"message": string(body)})
|
|
}
|
|
}
|