add: api key middleware

This commit is contained in:
$(pass /github/name)
2024-09-02 17:05:15 +02:00
parent 6ac2b32a1f
commit 1ad2f2090f
7 changed files with 121 additions and 35 deletions

View File

@@ -8,11 +8,20 @@ import (
)
func RegisterRoutes(router *gin.Engine, userController *controllers.UserController, membershipcontroller *controllers.MembershipController, contactController *controllers.ContactController) {
router.GET("/backend/verify", userController.VerifyMailHandler)
router.POST("/backend/api/register", userController.RegisterUser)
router.POST("/backend/api/register/subscription", membershipcontroller.RegisterSubscription)
router.POST("/backend/api/contact", contactController.RelayContactRequest)
// router.HandleFunc("/login", userController.LoginUser).Methods("POST")
router.GET("/verify", userController.VerifyMailHandler)
router.POST("/h/register", userController.RegisterUser)
router.POST("/h/contact", contactController.RelayContactRequest)
router.POST("/csp-report", middlewares.CSPReportHandling)
// create subrouter for teh authenticated area /account
// also pthprefix matches everything below /account
// accountRouter := router.PathPrefix("/account").Subrouter()
// accountRouter.Use(middlewares.AuthMiddleware)
//create api key required router
apiRouter := router.Group("/api")
{
router.POST("/subscription", membershipcontroller.RegisterSubscription)
}
apiRouter.Use(middlewares.APIKeyMiddleware())
}