feat: registered file based routing
This commit is contained in:
parent
69e3133563
commit
f2e666874d
2 changed files with 17 additions and 18 deletions
|
@ -1,26 +1,12 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"stereo.cat/backend/internal/api/routes"
|
||||
"stereo.cat/backend/internal/types"
|
||||
)
|
||||
|
||||
func Register(cfg *types.StereoConfig) []types.Route {
|
||||
routes := []types.Route{
|
||||
{
|
||||
Path: "/ping",
|
||||
Method: http.MethodGet,
|
||||
Exec: func(cfg *types.StereoConfig) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
c.String(http.StatusOK, "Pong!")
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
func Register(cfg *types.StereoConfig) {
|
||||
api := cfg.Router.Group("/api")
|
||||
|
||||
types.RegisterRoutes("/api", routes, cfg)
|
||||
|
||||
return routes
|
||||
routes.RegisterPingRoutes(api)
|
||||
}
|
||||
|
|
13
internal/api/routes/ping.go
Normal file
13
internal/api/routes/ping.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
package routes
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func RegisterPingRoutes(api *gin.RouterGroup) {
|
||||
api.GET("/ping", func(c *gin.Context) {
|
||||
c.String(http.StatusOK, "Pong!")
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue