24 lines
436 B
Go
24 lines
436 B
Go
package types
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type Route struct {
|
|
Path string
|
|
Method string
|
|
Exec func(cfg *StereoConfig) gin.HandlerFunc
|
|
}
|
|
|
|
type StereoConfig struct {
|
|
Router *gin.Engine
|
|
ImagePath 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))
|
|
}
|
|
}
|