Documentation
¶
Index ¶
- Constants
- Variables
- func FromContext(ctx context.Context) *db.Site
- func IsMediaPath(path string) bool
- func LookupHosts(rawHost, serverPort string) []string
- func NewUnresolved(bundle *i18n.Bundle, assets *static.Assets) http.Handler
- func PublicHost(value string) bool
- func Sandbox(w http.ResponseWriter, current *db.Site, mimeType string)
- func StripPort(rawHost string) string
- func ThemeURL(t *db.Theme) string
- func ThemeURLByID(ctx context.Context, d *db.DB, id *int64) (string, error)
- func ValidHost(value string) bool
- func WithSite(ctx context.Context, s *db.Site) context.Context
- func Zone(ctx context.Context) *time.Location
- type Action
- type Decision
- type HostRules
- type Lookup
- type Site
- type ThemeFiles
Constants ¶
const (
ThemePrefix = "/-/theme/"
)
Variables ¶
var MediaPrefixes = []string{
"/local--files/",
"/local--code/",
"/local--html/",
"/local--theme/",
}
Functions ¶
func FromContext ¶
FromContext returns nil when the request never passed through HostRules, which is every request in a test that builds its own.
func IsMediaPath ¶
func LookupHosts ¶
func NewUnresolved ¶
A wildcard DNS record sends every subdomain to this server, so a mistyped one has to land somewhere that says so.
func PublicHost ¶
func Sandbox ¶
func Sandbox(w http.ResponseWriter, current *db.Site, mimeType string)
A site whose files share its own domain would otherwise run an uploaded page with the visitor's session. The sandbox keeps the scripts but takes the origin away, and PDFs are spared because browsers refuse to show them sandboxed.
func ThemeURL ¶
A site with no usable theme loads nothing, so the base stylesheet stays the only thing under the site's own CSS, which is what a wikidot theme expects.
Types ¶
type Decision ¶
type HostRules ¶
type HostRules struct {
// contains filtered or unexported fields
}
HostRules is the redirect between the two domains plus the header pair that follows from which one the request arrived on. The asset bundle stays outside it, since it is answered before any of this runs.
func NewHostRules ¶
type ThemeFiles ¶
type ThemeFiles struct {
// contains filtered or unexported fields
}
func NewThemeFiles ¶
func NewThemeFiles(root string) *ThemeFiles
NewThemeFiles serves out of the theme directory under root, which is files/.
func (*ThemeFiles) ServeHTTP ¶
func (h *ThemeFiles) ServeHTTP(w http.ResponseWriter, r *http.Request)