register.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package routes
  2. import (
  3. "git.aetherial.dev/aeth/keiji/pkg/controller"
  4. "git.aetherial.dev/aeth/keiji/pkg/helpers"
  5. "github.com/gin-gonic/gin"
  6. )
  7. func Register(e *gin.Engine, domain string, redisPort string, redisAddr string, database helpers.DocumentIO) {
  8. c := controller.NewController(domain, redisPort, redisAddr, database)
  9. web := e.Group("")
  10. web.GET("/", c.ServeHome)
  11. web.GET("/blog", c.ServeBlog)
  12. web.GET("/digital", c.ServeDigitalArt)
  13. web.GET("/writing/:id", c.ServePost)
  14. web.GET("/login", c.ServeLogin)
  15. web.POST("/login", c.Auth)
  16. cdn := e.Group("/api/v1")
  17. cdn.GET("/images/:file", c.ServeImage)
  18. cdn.GET("/cdn/:file", c.ServeGeneric)
  19. cdn.GET("assets/:file", c.ServeAsset)
  20. priv := e.Group("/admin")
  21. priv.Use(c.IsAuthenticated)
  22. priv.GET("/upload", c.ServeFileUpload)
  23. priv.POST("/upload", c.SaveFile)
  24. priv.GET("/panel", c.AdminPanel)
  25. priv.POST("/panel", c.AddAdminTableEntry)
  26. priv.POST("/menu", c.AddMenuItem)
  27. priv.POST("/navbar", c.AddNavbarItem)
  28. priv.POST("/images/upload", c.SaveFile)
  29. priv.GET("/posts/:id", c.GetBlogPostEditor)
  30. priv.POST("/posts", c.MakeBlogPost)
  31. priv.GET("/posts/all", c.ServeBlogDirectory)
  32. priv.GET("/posts", c.ServeNewBlogPage)
  33. priv.PATCH("/posts", c.UpdateBlogPost)
  34. }