feat(template): add Templating functionality and endpoint
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user