Added site index file and created_at
This commit is contained in:
@@ -110,6 +110,9 @@ func validateIncomingSite(site *models.Site) error {
|
||||
if site.NotFoundFile == "" {
|
||||
site.NotFoundFile = "404.html"
|
||||
}
|
||||
if site.IndexFile == "" {
|
||||
site.IndexFile = "index.html"
|
||||
}
|
||||
if site.ForwardRules == nil {
|
||||
site.ForwardRules = []models.ForwardRule{}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ func NewStaticHandler(storagePath string, siteRepo repository.SiteRepository) fi
|
||||
}
|
||||
|
||||
if urlPath == "/" || urlPath == "." {
|
||||
urlPath = "/index.html"
|
||||
urlPath = "/" + site.IndexFile
|
||||
}
|
||||
|
||||
basePath := filepath.Join(storagePath, site.ID)
|
||||
@@ -71,7 +71,7 @@ func NewStaticHandler(storagePath string, siteRepo repository.SiteRepository) fi
|
||||
info, err := os.Stat(filePath)
|
||||
if err == nil {
|
||||
if info.IsDir() {
|
||||
indexPath := filepath.Join(filePath, "index.html")
|
||||
indexPath := filepath.Join(filePath, site.IndexFile)
|
||||
if _, err := os.Stat(indexPath); err == nil {
|
||||
return c.SendFile(indexPath)
|
||||
}
|
||||
@@ -81,7 +81,7 @@ func NewStaticHandler(storagePath string, siteRepo repository.SiteRepository) fi
|
||||
}
|
||||
|
||||
if site.Spa {
|
||||
indexPath := filepath.Join(basePath, "index.html")
|
||||
indexPath := filepath.Join(basePath, site.IndexFile)
|
||||
if _, err := os.Stat(indexPath); err == nil {
|
||||
return c.SendFile(indexPath)
|
||||
}
|
||||
|
||||
@@ -33,6 +33,9 @@ type Site struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
Spa bool `json:"spa"`
|
||||
NotFoundFile string `json:"not_found_file"`
|
||||
IndexFile string `json:"index_file"`
|
||||
TrailingSlash *bool `json:"trailing_slash"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
ForwardRules []ForwardRule `json:"forward_rules"`
|
||||
CustomHeaders []CustomHeaders `json:"custom_headers"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user