backend/internal/types/types.go

36 lines
628 B
Go

package types
import (
"time"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
)
type Route struct {
Path string
Method string
Exec func(cfg *StereoConfig) gin.HandlerFunc
}
type StereoConfig struct {
Router *gin.Engine
ImagePath string
}
type User struct {
gorm.Model
ID uint
Username string
RegistrationDate time.Time
Blacklisted bool
Email string
}
func RegisterRoutes(groupName string, routes []Route, cfg *StereoConfig) {
group := cfg.Router.Group(groupName)
for _, route := range routes {
group.Handle(route.Method, route.Path, route.Exec(cfg))
}
}