storage

package
v0.0.0-...-8e5f6f4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
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

func MigrateDeployPaths(db *gorm.DB, store *Manager) error

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

type HeaderRule struct {
	Path    string
	Headers map[string]string
}

func ParseHeaders

func ParseHeaders(filePath string) ([]HeaderRule, error)

type Manager

type Manager struct {
	BasePath string
}

func NewManager

func NewManager(basePath string) *Manager

func (*Manager) DeleteSite

func (m *Manager) DeleteSite(siteID string) error

func (*Manager) ExtractZip

func (m *Manager) ExtractZip(siteID string, deployKey string, reader io.ReaderAt, size int64) (extractErr error)

func (*Manager) GetDeploymentPath

func (m *Manager) GetDeploymentPath(siteID string, deployKey string) string

func (*Manager) GetWorkerBytecodeDir

func (m *Manager) GetWorkerBytecodeDir(siteID string, deployKey string) string

GetWorkerBytecodeDir returns the path to the .worker directory for a deployment.

func (*Manager) GetWorkerScript

func (m *Manager) GetWorkerScript(siteID string, deployKey string) (string, error)

GetWorkerScript reads the _worker.js source from a deployment.

func (*Manager) HasWorkerScript

func (m *Manager) HasWorkerScript(siteID string, deployKey string) bool

HasWorkerScript checks if a _worker.js file exists in the deployment.

func (*Manager) ResolveFile

func (m *Manager) ResolveFile(deploymentPath, requestPath string) (string, bool)

ResolveFile tries to find a file at the given request path. It checks: exact path, path/index.html, path.html

type RedirectRule

type RedirectRule struct {
	From       string
	To         string
	StatusCode int
}

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)

func (*SiteRulesCache) Set

func (c *SiteRulesCache) Set(siteID string, deployKey string, rules *SiteRules)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL