| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package domain |
||
| 2 | |||
| 3 | import "github.com/gofiber/fiber/v2" |
||
| 4 | |||
| 5 | // Permission is the permission level of a user. |
||
| 6 | type Permission int64 |
||
| 7 | |||
| 8 | const ( |
||
| 9 | PermissionNone Permission = iota // PermissionNone is the default permission level. |
||
| 10 | PermissionUser // PermissionUser is the permission level of a user. |
||
| 11 | PermissionVip // PermissionVip is the permission level of a vip. |
||
| 12 | PermissionAdmin // PermissionAdmin is the permission level of an admin. |
||
| 13 | ) |
||
| 14 | |||
| 15 | func (p Permission) String() string { |
||
| 16 | return [...]string{"none", "user", "vip", "admin"}[p] |
||
| 17 | } |
||
| 18 | |||
| 19 | func (p Permission) IsValid() bool { |
||
| 20 | return p >= PermissionNone && p <= PermissionAdmin |
||
| 21 | } |
||
| 22 | |||
| 23 | // Route is a route for the API |
||
| 24 | // It contains the handler, method and permission level. |
||
| 25 | type Route struct { |
||
| 26 | Handler func(c *fiber.Ctx) error // Handler is the handler function for the route. |
||
| 27 | Method string // Method is the method of the route. |
||
| 28 | Permission Permission // Permission is the permission level of the route. |
||
| 29 | } |
||
| 30 | |||
| 31 | type Model interface { |
||
| 32 | TableName() string |
||
| 33 | } |
||
| 34 |