rag/internal/routes/router.go

48 lines
1.3 KiB
Go
Raw Normal View History

2024-07-14 10:29:36 +00:00
package routes
2024-07-14 09:44:49 +00:00
import (
"github.com/gin-gonic/gin"
2024-07-14 14:29:59 +00:00
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
2024-07-14 15:58:23 +00:00
_ "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"
2024-07-14 09:44:49 +00:00
)
2024-07-14 14:14:27 +00:00
// @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
2024-07-14 14:29:59 +00:00
// @BasePath /
2024-07-14 14:14:27 +00:00
2024-07-14 14:29:59 +00:00
// @securityDefinitions.apikey ApiKeyAuth
//
2024-07-14 14:14:27 +00:00
// @in header
// @name Authorization
2024-07-14 14:29:59 +00:00
// @description Description for what is this security definition being used
// InitApiRoutes init api routes
2024-07-14 09:44:49 +00:00
func InitApiRoutes() {
2024-07-14 15:58:23 +00:00
var r = *providers.MustGet[gin.Engine]()
2024-07-14 14:29:59 +00:00
var userController = user.NewUserController()
r.GET("/", http.MiddlewareJSONResponse, http.RequireJWTIDToken, userController.CurrentUser)
}
2024-07-14 09:44:49 +00:00
2024-07-14 14:29:59 +00:00
// InitSwaggerRoutes init swagger routes
func InitSwaggerRoutes() {
2024-07-14 15:58:23 +00:00
var r = *providers.MustGet[gin.Engine]()
2024-07-14 14:29:59 +00:00
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
2024-07-14 09:44:49 +00:00
}