Reduce amount of manifest queries sent to the backend.

This commit is contained in:
Catherine
2025-09-17 06:20:42 +00:00
parent 6254176a17
commit 876b4596ba

View File

@@ -31,19 +31,19 @@ func getPage(w http.ResponseWriter, r *http.Request) error {
w.Header().Set("Access-Control-Max-Age", "86400")
urlPath, _ = strings.CutPrefix(r.URL.Path, "/")
manifest, err = backend.GetManifest(fmt.Sprintf("%s/.index", host))
if projectName, projectPath, found := strings.Cut(urlPath, "/"); found {
var projectManifest *Manifest
projectManifest, err = backend.GetManifest(fmt.Sprintf("%s/%s", host, projectName))
projectManifest, err := backend.GetManifest(fmt.Sprintf("%s/%s", host, projectName))
if err == nil {
urlPath = projectPath
manifest = projectManifest
urlPath, manifest = projectPath, projectManifest
}
}
if manifest == nil {
w.WriteHeader(http.StatusNotFound)
fmt.Fprintf(w, "site not found\n")
return err
manifest, err = backend.GetManifest(fmt.Sprintf("%s/.index", host))
if manifest == nil {
w.WriteHeader(http.StatusNotFound)
fmt.Fprintf(w, "site not found\n")
return err
}
}
entryPath := urlPath