mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 19:53:21 +02:00
feat: images
This commit is contained in:
+3
-8
@@ -1,18 +1,13 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"html/template"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
//go:embed static
|
||||
var staticFolder embed.FS
|
||||
|
||||
var headTmpl template.HTML
|
||||
|
||||
var contentTypes = map[string]string{
|
||||
@@ -97,11 +92,10 @@ func InitHeadTmpl() {
|
||||
func NewPageRouter() http.Handler {
|
||||
r := chi.NewRouter()
|
||||
|
||||
contentStatic := fs.FS(staticFolder)
|
||||
|
||||
InitHeadTmpl()
|
||||
|
||||
r.Handle("/static/*", StaticFileServerWithContentType(http.FS(contentStatic)))
|
||||
fileServer := StaticFileServerWithContentType(http.Dir("api/static"))
|
||||
r.Handle("/static/*", http.StripPrefix("/static/", fileServer))
|
||||
|
||||
r.Get("/", GetLogin)
|
||||
r.Get(LoginRoute, GetLoginPageHandler(EmptyLoginPage))
|
||||
@@ -128,6 +122,7 @@ func NewPageRouter() http.Handler {
|
||||
r.Get("/post/{id}/delete", GetPostDeletePage)
|
||||
r.Get("/post/create", GetPostCreatePage)
|
||||
r.Post("/post/create", PostPostCreatePage)
|
||||
r.Post("/post/{id}/image/create", postImage)
|
||||
})
|
||||
|
||||
return r
|
||||
|
||||
Reference in New Issue
Block a user