register.go 1.4 KB

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