package apis import ( "github.com/gin-gonic/gin" "log" "net/http" ) func SetupRouter(r *gin.Engine, authMiddleware gin.HandlerFunc) { r.NoRoute(func(c *gin.Context) { c.JSON(http.StatusNotFound, gin.H{ "error": "Resource not found", }) }) private := r.Group("/gui") // Gets the session from the cookie, and puts it in the current request. if authMiddleware != nil { private.Use(authMiddleware) } private.Use(func(c *gin.Context) { c.Next() for _, e := range c.Errors { log.Println(e.Error()) } }) r.GET("/ping", func(c *gin.Context) { c.JSON(http.StatusOK, gin.H{ "message": "pong", }) }) InitAuthEndpoints(private) InitUsersEndpoints(private) InitSystemsEndpoints(private) InitKeysEndpoints(private) }