From 55cc4a3614da24382c20cdc79f20bb035a66c8d8 Mon Sep 17 00:00:00 2001 From: Yanislav Igonin Date: Mon, 11 Apr 2022 11:19:19 +0300 Subject: [PATCH] feat: add redirect on post after post creation --- controllers/threads_controller.go | 7 ++++--- templates/components/post.html | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/controllers/threads_controller.go b/controllers/threads_controller.go index cafc407..8320e3b 100644 --- a/controllers/threads_controller.go +++ b/controllers/threads_controller.go @@ -212,7 +212,8 @@ func CreateThread(c *fiber.Ctx) error { tx.Commit(context.TODO()) - return c.Redirect("/"+strconv.Itoa(threadID), fiber.StatusFound) + path := "/" + strconv.Itoa(threadID) + return c.Redirect(path, fiber.StatusFound) } // Add new post in thread @@ -363,6 +364,6 @@ func UpdateThread(c *fiber.Ctx) error { tx.Commit(context.TODO()) - c.Append("Refresh", "0") - return c.SendStatus(fiber.StatusCreated) + path := "/" + strconv.Itoa(threadID) + "#" + strconv.Itoa(postID) + return c.Redirect(path) } diff --git a/templates/components/post.html b/templates/components/post.html index 97c386e..93f5bb3 100644 --- a/templates/components/post.html +++ b/templates/components/post.html @@ -1,5 +1,5 @@ {{ define "post" }} -
+