feat: post list and edition redirect

This commit is contained in:
Florian Sylvain
2024-05-17 16:38:41 +02:00
parent 24eefb743b
commit 900ad3e8b8
2062 changed files with 7238 additions and 24 deletions
+11 -1
View File
@@ -1,15 +1,25 @@
package api
import (
"github.com/go-chi/chi/v5"
"html/template"
"net/http"
)
func GetPostEditPage(w http.ResponseWriter, _ *http.Request) {
func GetPostEditPage(w http.ResponseWriter, r *http.Request) {
postName := chi.URLParam(r, "name")
if len(postName) == 0 {
w.WriteHeader(http.StatusBadRequest)
return
}
post, _ := Container.GetPostUseCase.GetPostByName(postName)
navbarTmpl, _ := Container.GetPageUseCase.GetPage("componentNavbar", nil)
postsTmpl, _ := Container.GetPageUseCase.GetPage("postEdit", map[string]interface{}{
"Navbar": template.HTML(navbarTmpl),
"Head": headTmpl,
"Body": post.Body,
})
_, _ = w.Write(postsTmpl)
}