feat(upload): add first prototype of File storage, svg database and svg processing. Also added --help command
All checks were successful
build / Go-Build (push) Successful in 1m5s

This commit is contained in:
2026-02-03 00:29:08 +01:00
parent 5bd6f3b312
commit 9574c2d0bc
9 changed files with 258 additions and 37 deletions

32
internal/server/http.go Normal file
View File

@@ -0,0 +1,32 @@
package server
import (
"fmt"
"log"
"net/http"
"tomatentum.net/svg-templater/internal/routes"
"tomatentum.net/svg-templater/pkg/auth"
)
func PrepareHTTP() {
registerAuthorized("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "You are authorized!")
})
registerAuthorized("/svg/", func(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
}
routes.CreateSVG(w, *r)
})
}
func Start() {
log.Println("Starting http server on :3000")
http.ListenAndServe(":3000", nil)
}
func registerAuthorized(path string, f func(w http.ResponseWriter, r *http.Request)) {
http.HandleFunc(path, auth.AuthMiddleware(http.HandlerFunc(f)))
log.Println("Registered authorized handler for", path)
}