feat(template): add Templating functionality and endpoint
All checks were successful
build / Go-Build (push) Successful in 1m38s
build / Go-Build (pull_request) Successful in 39s

This commit is contained in:
2026-02-09 11:09:19 +01:00
parent de3ba44093
commit 205b70eeab
7 changed files with 208 additions and 9 deletions

View File

@@ -4,7 +4,6 @@ import (
"fmt"
"log"
"net/http"
"path/filepath"
"tomatentum.net/svg-templater/internal/routes"
"tomatentum.net/svg-templater/pkg/auth"
@@ -20,10 +19,17 @@ func PrepareHTTP() {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
routes.CreateSVG(w, *r)
routes.CreateSVG(w, r)
})
registerAuthorizedFunc("/svg/{id}", func(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
routes.DownloadSVG(w, r)
})
registerAuthorized("/public/", http.StripPrefix("/public/", http.FileServer(svg.Storage.GetPublicDir())))
http.Handle("/public/", http.StripPrefix("/public/", http.FileServer(svg.Storage.GetPublicDir())))
}
func Start() {
@@ -41,7 +47,3 @@ func registerAuthorized(path string, handler http.Handler) {
func registerAuthorizedFunc(path string, f func(w http.ResponseWriter, r *http.Request)) {
registerAuthorized(path, http.HandlerFunc(f))
}
func GetPublicPath(path string) string {
return filepath.Join("public", path)
}