learnsteam-quiz-api/internal/routers/router.go

31 lines
814 B
Go
Raw Normal View History

2023-10-19 22:47:12 +09:00
package routers
import (
2023-11-17 01:38:01 +09:00
"learnsteam/learsteam-quiz-api/internal/database"
2023-10-19 22:47:12 +09:00
2023-11-17 01:38:01 +09:00
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
2023-10-19 22:47:12 +09:00
)
var Router *gin.Engine
func Init() {
gin.SetMode(gin.ReleaseMode)
Router = gin.Default()
2023-11-17 01:38:01 +09:00
config := cors.DefaultConfig()
config.AllowOrigins = []string{"http://127.0.0.1:3000", "http://localhost:3000", "http://localhost:3030", "https://learnsteam-quiz.jongyeob.com"}
config.AllowMethods = []string{"GET", "POST", "PUT", "DELETE", "PATCH"}
config.AllowHeaders = []string{"Origin", "Content-Length", "Content-Type"}
Router.Use(cors.New(config))
2023-10-19 22:47:12 +09:00
maindb := database.GetDB()
InitAuthRouter(maindb, Router)
InitTokenRouter(maindb, Router)
InitUserRouter(maindb, Router)
2023-11-17 01:38:01 +09:00
InitProgramRouter(maindb, Router)
InitQuizRouter(maindb, Router)
InitSwaggerRouter(Router)
2023-10-19 22:47:12 +09:00
}