server/qa/api/router.go

35 lines
801 B
Go
Raw Normal View History

package api
import (
"net/http"
2022-11-06 15:36:31 +00:00
"github.com/gin-gonic/gin"
)
2022-11-06 15:36:31 +00:00
func DeclareRoutes(router *gin.RouterGroup) {
apiRoutes := router.Group("/api")
apiRoutes.Use(authMiddleware())
2022-11-06 15:36:31 +00:00
declareExercicesRoutes(apiRoutes)
declareQARoutes(apiRoutes)
declareThemesRoutes(apiRoutes)
declareTodoRoutes(apiRoutes)
declareVersionRoutes(apiRoutes)
2023-11-25 12:43:41 +00:00
declareGitlabRoutes(router, apiRoutes)
apiManagerRoutes := router.Group("/api")
apiManagerRoutes.Use(authMiddleware(func(ficteam string, teamid int64, c *gin.Context) bool {
for _, manager := range ManagerUsers {
if manager == ficteam {
return true
}
}
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"errmsg": "Not authorized."})
return false
}))
declareTodoManagerRoutes(apiManagerRoutes)
declareTeamsRoutes(apiManagerRoutes)
}