aboutsummaryrefslogtreecommitdiff
path: root/cmd/web/route
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/web/route')
-rw-r--r--cmd/web/route/handlers.go39
-rw-r--r--cmd/web/route/htmx-handlers.go50
2 files changed, 89 insertions, 0 deletions
diff --git a/cmd/web/route/handlers.go b/cmd/web/route/handlers.go
new file mode 100644
index 0000000..0131fe8
--- /dev/null
+++ b/cmd/web/route/handlers.go
@@ -0,0 +1,39 @@
+package webroute
+
+import (
+ "projecty/cmd/web/controller"
+
+ "github.com/gofiber/fiber/v2"
+)
+
+type PageData struct {
+ PageTitle string
+}
+
+func WebHandlers(app *fiber.App) {
+
+ /* Sign In */
+ app.Get("/sign-in", controller.SignInPage)
+
+ /* Sign Up */
+ app.Get("/sign-up", controller.SignUpPage)
+
+ /* Home */
+ app.Get("/", controller.HomePage)
+ app.Get("/your-feed", controller.YourFeedPage)
+ app.Get("/tag-feed/:slug", controller.TagFeedPage)
+
+ /* Article */
+ app.Get("/articles/:slug", controller.ArticleDetailPage)
+
+ /* Editor */
+ app.Get("/editor/:slug?", controller.EditorPage)
+
+ /* User */
+ app.Get("/users/:username", controller.UserDetailPage)
+ app.Get("/users/:username/articles", controller.UserDetailPage)
+ app.Get("/users/:username/favorites", controller.UserDetailFavoritePage)
+
+ /* Setting */
+ app.Get("/settings", controller.SettingPage)
+}
diff --git a/cmd/web/route/htmx-handlers.go b/cmd/web/route/htmx-handlers.go
new file mode 100644
index 0000000..4470c91
--- /dev/null
+++ b/cmd/web/route/htmx-handlers.go
@@ -0,0 +1,50 @@
+package webroute
+
+import (
+ HTMXController "projecty/cmd/web/controller/htmx"
+
+ "github.com/gofiber/fiber/v2"
+)
+
+func HTMXHandlers(app *fiber.App) {
+
+ /* Sign In */
+ app.Get("/htmx/sign-in", HTMXController.SignInPage)
+ app.Post("/htmx/sign-in", HTMXController.SignInAction)
+ app.Post("/htmx/sign-out", HTMXController.SignOut)
+
+ /* Sign Up */
+ app.Get("/htmx/sign-up", HTMXController.SignUpPage)
+ app.Post("/htmx/sign-up", HTMXController.SignUpAction)
+
+ /* Home */
+ app.Get("/htmx/home", HTMXController.HomePage)
+ app.Get("/htmx/home/your-feed", HTMXController.HomeYourFeed)
+ app.Get("/htmx/home/global-feed", HTMXController.HomeGlobalFeed)
+ app.Get("/htmx/home/tag-feed/:tag", HTMXController.HomeTagFeed)
+ app.Get("/htmx/home/tag-list", HTMXController.HomeTagList)
+ app.Post("/htmx/home/articles/:slug/favorite", HTMXController.HomeFavoriteAction)
+
+ /* Article */
+ app.Get("/htmx/articles/:slug", HTMXController.ArticleDetailPage)
+ app.Get("/htmx/articles/:slug/comments", HTMXController.ArticleDetailCommentList)
+ app.Post("/htmx/articles/:slug/comments", HTMXController.ArticleComment)
+ app.Post("/htmx/articles/:slug/favorite", HTMXController.ArticleFavoriteAction)
+ app.Post("/htmx/articles/follow-user/:slug", HTMXController.ArticleFollowAction)
+
+ /* Editor */
+ app.Get("/htmx/editor/:slug?", HTMXController.EditorPage)
+ app.Post("/htmx/editor", HTMXController.StoreArticle)
+ app.Patch("/htmx/editor/:slug?", HTMXController.UpdateArticle)
+
+ /* User */
+ app.Get("/htmx/users/:username", HTMXController.UserDetailPage)
+ app.Get("/htmx/users/:username/articles", HTMXController.UserArticles)
+ app.Get("/htmx/users/:username/favorites", HTMXController.UserArticlesFavorite)
+ app.Post("/htmx/users/articles/:slug/favorite", HTMXController.UserArticleFavoriteAction)
+ app.Post("/htmx/users/:username/follow", HTMXController.UserFollowAction)
+
+ /* Setting */
+ app.Get("/htmx/settings", HTMXController.SettingPage)
+ app.Post("/htmx/settings", HTMXController.SettingAction)
+}