recommender/internal/router/api.go

40 lines
794 B
Go
Raw Normal View History

2024-11-06 10:47:56 +00:00
package router
import (
"github.com/gin-gonic/gin"
2024-11-06 12:35:16 +00:00
"leafdev.top/Ecosystem/recommender/internal/handler/http"
2024-11-06 10:47:56 +00:00
)
// 两种方法都可以
//type Api struct {
// User *v1.UserController
//}
type Api struct {
2024-11-07 10:09:13 +00:00
h *http.Handlers
2024-11-06 10:47:56 +00:00
}
func NewApiRoute(
2024-11-07 10:09:13 +00:00
h *http.Handlers,
2024-11-06 10:47:56 +00:00
) *Api {
return &Api{
2024-11-07 10:09:13 +00:00
h,
2024-11-06 10:47:56 +00:00
}
}
func (a *Api) InitApiRouter(r *gin.RouterGroup) {
2024-11-07 12:00:06 +00:00
r.GET("/applications", a.h.ApplicationController.List)
r.POST("/applications", a.h.ApplicationController.Save)
r.GET("/application/:application_id/tokens", a.h.ApplicationController.ListToken)
r.POST("/application/:application_id/tokens", a.h.ApplicationController.SaveToken)
2024-11-06 10:47:56 +00:00
}
func (a *Api) InitNoAuthApiRouter(r *gin.RouterGroup) {
}
2024-11-07 12:00:06 +00:00
func (a *Api) InitApplicationApi(r *gin.RouterGroup) {
r.GET("/info", a.h.ApplicationApi.Info)
}