mirror of
https://codeberg.org/git-pages/git-pages.git
synced 2026-08-17 09:26:04 +00:00
Add a domain cache to quickly reject non-existent domains.
This commit is contained in:
+12
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user