mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-05 03:02:56 +00:00
upload
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"fotbal-club/internal/controllers"
|
||||
"fotbal-club/internal/middleware"
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func RegisterEventRoutes(router *gin.RouterGroup, db *gorm.DB) {
|
||||
eventController := controllers.EventController{DB: db}
|
||||
|
||||
events := router.Group("/events")
|
||||
{
|
||||
events.GET("", eventController.GetEvents)
|
||||
events.GET("/upcoming", eventController.GetUpcomingEvents)
|
||||
// Public single event endpoint
|
||||
events.GET(":id", eventController.GetEventByID)
|
||||
|
||||
// Protected routes
|
||||
authorized := events.Group("")
|
||||
authorized.Use(middleware.JWTAuth(db))
|
||||
{
|
||||
authorized.POST("", eventController.CreateEvent)
|
||||
authorized.PUT(":id", eventController.UpdateEvent)
|
||||
authorized.DELETE(":id", eventController.DeleteEvent)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user