func AddRole(db *database.Database) fiber.Handler {
	return func(ctx *fiber.Ctx) error {
		Role := new(models.Role)
		if err := ctx.BodyParser(Role); err != nil {
			panic("An error occurred when parsing the new role: " + err.Error())
		}
		if response := db.Create(&Role); response.Error != nil {
			panic("An error occurred when storing the new role: " + response.Error.Error())
		}
		err := ctx.JSON(Role)
		if err != nil {
			panic("Error occurred when returning JSON of a role: " + err.Error())
		}
		return err
	}
}
Add a single role to the database
package api
import (
	"fiber-boilerplate/app/models"
	"fiber-boilerplate/database"
	"github.com/gofiber/fiber/v2"
)
func GetAllRoles(db *database.Database) fiber.Handler {
	return func(ctx *fiber.Ctx) error {
		var Role []models.Role
		if response := db.Find(&Role); response.Error != nil {
			panic("Error occurred while retrieving roles from the database: " + response.Error.Error())
		}
		err := ctx.JSON(Role)
		if err != nil {
			panic("Error occurred when returning JSON of roles: " + err.Error())
		}
		return err
	}
}
func GetRole(db *database.Database) fiber.Handler {
	return func(ctx *fiber.Ctx) error {
		Role := new(models.Role)
		id := ctx.Params("id")
		if response := db.Find(&Role, id); response.Error != nil {
			panic("An error occurred when retrieving the role: " + response.Error.Error())
		}
		if Role.ID == 0 {
			err := ctx.SendStatus(fiber.StatusNotFound)
			if err != nil {
				panic("Cannot return status not found: " + err.Error())
			}
			err = ctx.JSON(fiber.Map{
				"ID": id,
			})
			if err != nil {
				panic("Error occurred when returning JSON of a role: " + err.Error())
			}
			return err
		}
		err := ctx.JSON(Role)
		if err != nil {
			panic("Error occurred when returning JSON of a role: " + err.Error())
		}
		return err
	}
}