Documentation
¶
Index ¶
- Constants
- func MatchHeaders(rules []HeaderRule, path string) map[string]string
- func MigrateDeployPaths(db *gorm.DB, store *Manager) error
- type HeaderRule
- type Manager
- func (m *Manager) DeleteSite(siteID string) error
- func (m *Manager) ExtractZip(siteID string, deployKey string, reader io.ReaderAt, size int64) (extractErr error)
- func (m *Manager) GetDeploymentPath(siteID string, deployKey string) string
- func (m *Manager) GetWorkerBytecodeDir(siteID string, deployKey string) string
- func (m *Manager) GetWorkerScript(siteID string, deployKey string) (string, error)
- func (m *Manager) HasWorkerScript(siteID string, deployKey string) bool
- func (m *Manager) ResolveFile(deploymentPath, requestPath string) (string, bool)
- type RedirectRule
- type SiteRules
- type SiteRulesCache
Constants ¶
const (
MaxZipSize = 25 << 20 // 25 MB compressed upload
)
Variables ¶
This section is empty.
Functions ¶
func MatchHeaders ¶
func MatchHeaders(rules []HeaderRule, path string) map[string]string
MatchHeaders returns all headers that apply to the given path.
func MigrateDeployPaths ¶
MigrateDeployPaths backfills ActiveDeployID for existing sites that have ActiveVersion set but no ActiveDeployID, and renames the on-disk deployment directories from numeric version paths ({siteID}/{version}) to deploy ID paths ({siteID}/{deployID}).
This is a one-time data migration for the version→deployKey refactor. It is safe to run multiple times (idempotent).
Types ¶
type HeaderRule ¶
func ParseHeaders ¶
func ParseHeaders(filePath string) ([]HeaderRule, error)
type Manager ¶
type Manager struct {
BasePath string
}
func NewManager ¶
func (*Manager) DeleteSite ¶
func (*Manager) ExtractZip ¶
func (*Manager) GetDeploymentPath ¶
func (*Manager) GetWorkerBytecodeDir ¶
GetWorkerBytecodeDir returns the path to the .worker directory for a deployment.
func (*Manager) GetWorkerScript ¶
GetWorkerScript reads the _worker.js source from a deployment.
func (*Manager) HasWorkerScript ¶
HasWorkerScript checks if a _worker.js file exists in the deployment.
type RedirectRule ¶
func MatchRedirect ¶
func MatchRedirect(rules []RedirectRule, path string) (*RedirectRule, string, bool)
MatchRedirect checks if the request path matches any redirect rule. Returns the matched rule, the resolved target path, and whether a match was found.
func ParseRedirects ¶
func ParseRedirects(filePath string) ([]RedirectRule, error)
type SiteRules ¶
type SiteRules struct {
Redirects []RedirectRule
Headers []HeaderRule
}
type SiteRulesCache ¶
type SiteRulesCache struct {
// contains filtered or unexported fields
}
SiteRulesCache is a bounded cache with TTL-based eviction for parsed _redirects and _headers rules. It caps at maxCacheEntries and evicts stale entries on access and periodically during Set.
func NewSiteRulesCache ¶
func NewSiteRulesCache() *SiteRulesCache
func (*SiteRulesCache) Get ¶
func (c *SiteRulesCache) Get(siteID string, deployKey string) (*SiteRules, bool)
func (*SiteRulesCache) Invalidate ¶
func (c *SiteRulesCache) Invalidate(siteID string, deployKey string)