mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-05 03:02:56 +00:00
de day #74
This commit is contained in:
@@ -53,6 +53,7 @@ func SetupRoutes(api *gin.RouterGroup, db *gorm.DB) {
|
||||
imageProcessingController := &controllers.ImageProcessingController{}
|
||||
articleController := controllers.NewArticleController(db)
|
||||
myuibrixController := &controllers.MyUIbrixController{DB: db}
|
||||
shortLinkController := controllers.NewShortLinkController(db)
|
||||
|
||||
// API v1 group
|
||||
{
|
||||
@@ -151,6 +152,14 @@ func SetupRoutes(api *gin.RouterGroup, db *gorm.DB) {
|
||||
protectedEvents.DELETE("/:id", eventController.DeleteEvent)
|
||||
}
|
||||
|
||||
// Shortlinks (protected for editors) - create/list
|
||||
protectedShortlinks := protected.Group("/shortlinks")
|
||||
protectedShortlinks.Use(middleware.RoleAuth("editor"))
|
||||
{
|
||||
protectedShortlinks.POST("", shortLinkController.CreateShortLink)
|
||||
protectedShortlinks.GET("", shortLinkController.ListShortLinks)
|
||||
}
|
||||
|
||||
// Articles (protected - accessible by editors and admins)
|
||||
articles := protected.Group("/articles")
|
||||
articles.Use(middleware.RoleAuth("editor"))
|
||||
@@ -284,6 +293,7 @@ func SetupRoutes(api *gin.RouterGroup, db *gorm.DB) {
|
||||
admin.POST("/newsletter/test", contactController.SendNewsletterTest)
|
||||
// New: send prebuilt digest by type and toggle automation
|
||||
admin.POST("/newsletter/send-digest", contactController.SendNewsletterDigest)
|
||||
admin.POST("/newsletter/smtp-test", contactController.AdminSmtpTest)
|
||||
admin.PATCH("/newsletter/enable", contactController.UpdateNewsletterAutomation)
|
||||
// Removed deprecated SMTP test route (use /newsletter/test instead)
|
||||
admin.GET("/newsletter/status", contactController.GetNewsletterStatus)
|
||||
@@ -405,6 +415,14 @@ func SetupRoutes(api *gin.RouterGroup, db *gorm.DB) {
|
||||
myuibrix.GET("/preview", myuibrixController.GetElementPreview)
|
||||
myuibrix.GET("/optimize-layout", myuibrixController.OptimizePageLayout)
|
||||
}
|
||||
|
||||
// Short links (admin)
|
||||
shortlinks := admin.Group("/shortlinks")
|
||||
{
|
||||
shortlinks.POST("", shortLinkController.CreateShortLink)
|
||||
shortlinks.GET("", shortLinkController.ListShortLinks)
|
||||
shortlinks.GET("/:id/stats", shortLinkController.GetShortLinkStats)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -517,6 +535,10 @@ func SetupRoutes(api *gin.RouterGroup, db *gorm.DB) {
|
||||
// SetupRootRoutes registers endpoints at the root (no /api prefix)
|
||||
func SetupRootRoutes(r *gin.Engine, db *gorm.DB) {
|
||||
seoController := controllers.NewSEOController(db)
|
||||
shortLinkController := controllers.NewShortLinkController(db)
|
||||
r.GET("/robots.txt", seoController.GetRobotsTXT)
|
||||
r.GET("/sitemap.xml", seoController.GetSitemapXML)
|
||||
// Public short-link redirects and generic tracked redirect
|
||||
r.GET("/s/:code", shortLinkController.RedirectShort)
|
||||
r.GET("/r", shortLinkController.RedirectAndTrack)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user