http

package
v0.0.0-...-ac808a3 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPageNotCMS        = errors.New("page is not cms")
	ErrPageRequestMethod = errors.New("page request method is not allowed")
)
View Source
var ErrSiteNotFound = errors.New("site not found")

Functions

func DecorableFrom

func DecorableFrom(ctx context.Context) bool

func Host

func Host(r *http.Request) string

func Languages

func Languages(r *http.Request) []string

func MatchRequest

func MatchRequest(site cms.Site, r *http.Request) (string, error)

func NotDecorableFrom

func NotDecorableFrom(ctx context.Context) bool

func PageFrom

func PageFrom(ctx context.Context) (cms.Page, bool)

func PreferredLanguage

func PreferredLanguage(locales []string, r *http.Request) string

func PreferredSite

func PreferredSite(sites []cms.Site, r *http.Request) cms.Site

func Scheme

func Scheme(r *http.Request) string

func SetDecoratorHeaders

func SetDecoratorHeaders(ctx context.Context, w http.ResponseWriter)

func SiteFrom

func SiteFrom(ctx context.Context) (cms.Site, bool)

func WithDecorable

func WithDecorable(ctx context.Context, decorable bool) context.Context

func WithNotDecorable

func WithNotDecorable(ctx context.Context, notDecorable bool) context.Context

func WithPage

func WithPage(ctx context.Context, page cms.Page) context.Context

func WithPageSEO

func WithPageSEO(ctx context.Context, page cms.Page) context.Context

func WithSEO

func WithSEO(ctx context.Context, seo PageSEO) context.Context

func WithSite

func WithSite(ctx context.Context, site cms.Site) context.Context

func WithSiteSEO

func WithSiteSEO(ctx context.Context, site cms.Site) context.Context

Types

type DecoratorStrategy

type DecoratorStrategy interface {
	IsDecorable(r *http.Request, routeName string) bool
	IsRouteNameDecorable(ctx context.Context, routeName string) bool
	IsRouteURIDecorable(ctx context.Context, uri string) bool
}

func NewDecoratorStrategy

func NewDecoratorStrategy(ignore Ignore) DecoratorStrategy

type HostByLocaleSiteSelector

type HostByLocaleSiteSelector struct {
	// contains filtered or unexported fields
}

func NewHostByLocaleSiteSelector

func NewHostByLocaleSiteSelector(siteService cms.SiteService) HostByLocaleSiteSelector

func (HostByLocaleSiteSelector) Select

func (HostByLocaleSiteSelector) Type

type HostPathByLocaleSiteSelector

type HostPathByLocaleSiteSelector struct {
	// contains filtered or unexported fields
}

func NewHostPathByLocaleSiteSelector

func NewHostPathByLocaleSiteSelector(siteService cms.SiteService) HostPathByLocaleSiteSelector

func (HostPathByLocaleSiteSelector) Select

func (HostPathByLocaleSiteSelector) Type

type HostPathSiteSelector

type HostPathSiteSelector struct {
	// contains filtered or unexported fields
}

func NewHostPathSiteSelector

func NewHostPathSiteSelector(siteService cms.SiteService) HostPathSiteSelector

func (HostPathSiteSelector) Select

func (HostPathSiteSelector) Type

type HostSiteSelector

type HostSiteSelector struct {
	// contains filtered or unexported fields
}

func NewHostSiteSelector

func NewHostSiteSelector(siteService cms.SiteService) HostSiteSelector

func (HostSiteSelector) Select

func (s HostSiteSelector) Select(r *http.Request) (cms.Site, string, error)

func (HostSiteSelector) Type

func (s HostSiteSelector) Type() SelectorType

type Ignore

type Ignore interface {
	GetIgnoreRoutes(ctx context.Context) []string
	GetIgnoreRoute(ctx context.Context) []*regexp2.Regexp
	GetIgnoreURI(ctx context.Context) []*regexp2.Regexp
}

type PageRouter

type PageRouter interface {
	Match(ctx context.Context, site cms.Site, method string, path string) (cms.Page, error)
}

func NewPageRouter

func NewPageRouter(service cms.PageService) PageRouter

type PageSEO

type PageSEO interface {
	AddFromSite(site cms.Site) PageSEO
	AddFromPage(page cms.Page) PageSEO
	Title() string
	SetTitle(title string) PageSEO
	AddTitlePrefix(prefix string) PageSEO
	AddTitleSuffix(suffix string) PageSEO
	OriginalTitle() string
	SetSeparator(separator string) PageSEO
	Metas() map[string]map[string]string
	SetMetas(metas map[string]map[string]string) PageSEO
	AddMeta(typ, name, content string) PageSEO
	RemoveMeta(typ, name string) PageSEO
	HasMeta(typ, name string) bool
	HTMLAttributes() map[string]string
	SetHTMLAttributes(attrs map[string]string) PageSEO
	AddHTMLAttribute(name, content string) PageSEO
	RemoveHTMLAttribute(name string) PageSEO
	HasHTMLAttribute(name string) bool
	HeadAttributes() map[string]string
	SetHeadAttributes(attrs map[string]string) PageSEO
	AddHeadAttribute(name, content string) PageSEO
	RemoveHeadAttribute(name string) PageSEO
	HasHeadAttribute(name string) bool
	LinkCanonical() string
	SetLinkCanonical(link string) PageSEO
	RemoveLinkCanonical() PageSEO
	LangAlternates() map[string]string
	SetLangAlternates(langAlternates map[string]string) PageSEO
	AddLangAlternate(href, hreflang string) PageSEO
	RemoveLangAlternate(href string) PageSEO
	HasLangAlternate(href string) bool
	OEmbedLinks() map[string]string
	AddOEmbedLink(title, link string) PageSEO
}

func NewPageSEO

func NewPageSEO() PageSEO

func SEOFrom

func SEOFrom(ctx context.Context) PageSEO

type SelectorType

type SelectorType string
const (
	HostSelector             SelectorType = "host"
	HostByLocaleSelector     SelectorType = "host_by_locale"
	HostPathSelector         SelectorType = "host_with_path"
	HostPathByLocaleSelector SelectorType = "host_with_path_by_locale"
)

func (SelectorType) String

func (t SelectorType) String() string

type SiteSelector

type SiteSelector interface {
	Type() SelectorType
	Select(r *http.Request) (cms.Site, string, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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