rag/internal/routes/router.go
2024-07-14 23:58:23 +08:00

48 lines
1.3 KiB
Go

package routes
import (
"github.com/gin-gonic/gin"
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
_ "leafdev.top/leaf/rag/docs"
"leafdev.top/leaf/rag/internal/handlers/controllers/user"
"leafdev.top/leaf/rag/internal/middleware/http"
"leafdev.top/leaf/rag/internal/providers"
)
// @title Swagger Example API
// @version 1.0
// @description This is a sample server celler server.
// @termsOfService http://swagger.io/terms/
// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email support@swagger.io
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @host localhost:8080
// @BasePath /
// @securityDefinitions.apikey ApiKeyAuth
//
// @in header
// @name Authorization
// @description Description for what is this security definition being used
// InitApiRoutes init api routes
func InitApiRoutes() {
var r = *providers.MustGet[gin.Engine]()
var userController = user.NewUserController()
r.GET("/", http.MiddlewareJSONResponse, http.RequireJWTIDToken, userController.CurrentUser)
}
// InitSwaggerRoutes init swagger routes
func InitSwaggerRoutes() {
var r = *providers.MustGet[gin.Engine]()
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
}