package models import "time" // The match kinds of a redirect source (D-17). const ( RedirectExact = "exact" RedirectPattern = "pattern" RedirectRegex = "regex" ) // The statuses of a redirect (D-16). const ( Status301 = 301 Status302 = 302 Status410 = 410 ) // The query string options of a redirect (D-17). const ( QueryIgnore = "ignore" QueryPass = "pass" ) // The origins of a redirect: who created it. const ( OriginManual = "manual" OriginSlug = "slug" OriginImport = "import" OriginMCP = "mcp" OriginNotFound = "notfound" ) // Redirect is one redirect rule on golem15_seo_redirects (D-16, D-17): // Source is a path (exact, optionally with a query), a pattern where * // matches any text, or a regular expression; Target is a path or an // absolute URL, empty for 410 Gone. IgnoreCase compares the source without // letter case; TrailingSlash matches the source with and without a // trailing slash; Query ignores the request's query string or passes it to // the target. Origin records who created the rule. type Redirect struct { ID uint `gorm:"column:id;primaryKey"` Source string `gorm:"column:source"` Match string `gorm:"column:match"` Target string `gorm:"column:target"` Status int `gorm:"column:status"` Query string `gorm:"column:query"` IgnoreCase bool `gorm:"column:ignore_case"` TrailingSlash bool `gorm:"column:trailing_slash"` Origin string `gorm:"column:origin"` Note string `gorm:"column:note"` CreatedAt *time.Time `gorm:"column:created_at"` UpdatedAt *time.Time `gorm:"column:updated_at"` } func (Redirect) TableName() string { return "golem15_seo_redirects" } // MorphName names a redirect in history. func (Redirect) MorphName() string { return `Golem15\SEO\Models\Redirect` } // NewRedirect is a redirect with the form's defaults: exact, 301, query // ignored, trailing slash matched, manual. func NewRedirect() Redirect { return Redirect{Match: RedirectExact, Status: Status301, Query: QueryIgnore, TrailingSlash: true, Origin: OriginManual} } func init() { Register(Redirect{}) }