package server import ( "net/http" "os" "path/filepath" "strings" "git.linuxit.ro/turos.robert/mynotes/lib/inout" ) func Wildcard(w http.ResponseWriter, r *http.Request) { if r.Method == "GET" { endpoint := strings.TrimPrefix(r.URL.Path, "/") if endpoint == "" { //in cazul in care apelam root endpoint = "index" } path := filepath.Join("templates", endpoint+".tmpl") _, err := os.Stat(path) if err != nil { w.WriteHeader(http.StatusNotFound) w.Write(inout.FileToBytes("templates/error.tmpl")) return } w.Write(inout.FileToBytes(path)) return } }