Capstone/ui/controllers/controllers.go

43 lines
890 B
Go
Raw Normal View History

2023-10-28 14:42:29 -04:00
package controllers
import (
2023-10-28 17:50:44 -04:00
"git.preston-baxter.com/Preston_PLB/capstone/frontend-service/config"
"git.preston-baxter.com/Preston_PLB/capstone/frontend-service/db"
2023-10-28 14:42:29 -04:00
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
2023-10-28 14:42:29 -04:00
)
2023-10-28 17:50:44 -04:00
var mongo *db.DB
var log *logrus.Logger
2023-10-28 14:42:29 -04:00
func BuildRouter(r *gin.Engine) {
2023-10-28 17:50:44 -04:00
conf := config.Config()
var err error
mongo, err = db.NewClient(conf.Mongo.Uri)
if err != nil {
panic(err)
}
log = logrus.New()
log.SetFormatter(&logrus.TextFormatter{
ForceColors: true,
})
r.GET("/", AuthMiddleware(false), LandingPage)
r.GET("/login", AuthMiddleware(false), LoginPage)
r.GET("/signup",AuthMiddleware(false), SignUpPage)
2023-10-28 14:42:29 -04:00
2023-10-28 17:50:44 -04:00
r.POST("/login", LoginHandler)
r.POST("/signup", SignUpHandler)
r.POST("/logout", LogoutHandler)
2023-10-28 14:42:29 -04:00
2023-10-28 17:50:44 -04:00
dashboard := r.Group("/dashboard")
dashboard.Use(AuthMiddleware(true))
2023-10-28 17:50:44 -04:00
dashboard.GET("/", DashboardPage)
2023-10-28 14:42:29 -04:00
}
2023-10-28 17:50:44 -04:00