Add a domain cache to quickly reject non-existent domains.

This commit is contained in:
miyuko
2026-04-13 13:45:16 +00:00
parent f400f8d246
commit bbdaae7280
12 changed files with 225 additions and 5 deletions
+12 -1
View File
@@ -65,8 +65,12 @@ func observeSiteUpdate(via string, result *UpdateResult) {
}
}
func normalizeHost(host string) string {
return strings.ToLower(host)
}
func makeWebRoot(host string, projectName string) string {
return path.Join(strings.ToLower(host), projectName)
return path.Join(normalizeHost(host), projectName)
}
func getWebRoot(r *http.Request) (string, error) {
@@ -115,6 +119,13 @@ func getPage(w http.ResponseWriter, r *http.Request) error {
return err
}
host = normalizeHost(host)
if !domainCache.CheckDomain(r.Context(), host) {
w.WriteHeader(http.StatusNotFound)
fmt.Fprintf(w, "site not found\n")
return nil
}
type indexManifestResult struct {
manifest *Manifest
metadata ManifestMetadata