Documentation ¶
Index ¶
- Variables
- func APIAuthorizer(authorizer echox.Authorizer) api.Authorizer
- func Authorizer(authorizer rbac.Authorizer) echox.Authorizer
- func BasicAuthValidator(repo repository.Admin, logger *zap.Logger) middleware.BasicAuthValidator
- func BuildTree(nodes []model.Node, id int64) *model.Node
- func CtxAdmin(ctx context.Context) *model.Admin
- func CtxData(ctx context.Context) map[string]any
- func CtxDebug(ctx context.Context) bool
- func CtxEditor(ctx context.Context) bool
- func CtxPage(ctx context.Context) *model.Page
- func CtxSEO(ctx context.Context) seo.SEO
- func CtxSite(ctx context.Context) *model.Site
- func CtxTwoFA(ctx context.Context) bool
- func CtxURL(ctx context.Context) url.URL
- func Host(r *http.Request) string
- func IsAjax(r *http.Request) bool
- func IsTLS(r *http.Request) bool
- func IsTextHTML(header http.Header) bool
- func JWTAuthValidator(repo repository.Admin, secret string) middleware.KeyAuthValidator
- func Languages(r *http.Request) []string
- func MediaType(header http.Header) string
- func NewJWT(payload jwt.MapClaims, signingKey string, exp time.Duration) (string, error)
- func PageDecorate(w http.ResponseWriter) bool
- func PageNotDecorate(w http.ResponseWriter) bool
- func ParseJWT(token string, verificationKey string) (jwt.MapClaims, error)
- func ParseUnverifiedJWT(token string) (jwt.MapClaims, error)
- func RandomString(length int) string
- func Scheme(r *http.Request) string
- func SetSkipSelectPage(ctx context.Context) context.Context
- func SetSkipSelectSite(ctx context.Context) context.Context
- func SkipSelectPage(ctx context.Context) bool
- func SkipSelectSite(ctx context.Context) bool
- func WithAdmin(ctx context.Context, admin *model.Admin) context.Context
- func WithData(ctx context.Context, data map[string]any) context.Context
- func WithDebug(ctx context.Context, debug bool) context.Context
- func WithEditor(ctx context.Context, isEditor bool) context.Context
- func WithPage(ctx context.Context, m *model.Page) context.Context
- func WithPageDecorate(w http.ResponseWriter, value string)
- func WithSEO(ctx context.Context, s seo.SEO) context.Context
- func WithSite(ctx context.Context, m *model.Site) context.Context
- func WithTwoFA(ctx context.Context, twoFA bool) context.Context
- func WithURL(ctx context.Context, u url.URL) context.Context
- type AdminService
- func (s *AdminService) ChangePassword(ctx context.Context, email, password string) error
- func (s *AdminService) ChangeRoles(ctx context.Context, email string, roles ...string) error
- func (s *AdminService) Create(ctx context.Context, email, password, issuer string, roles ...string) (model.Admin, string, error)
- func (s *AdminService) GetOTPKey(ctx context.Context, email, issuer string, newOTP bool) (string, error)
- type Cache
- type DefaultMatcher
- type DefaultMenu
- type DefaultPageHandler
- type DefaultSeeder
- func (s *DefaultSeeder) Boot(ctx context.Context) error
- func (s *DefaultSeeder) CreateErrorPages(ctx context.Context, site model.Site) error
- func (s *DefaultSeeder) FindOrCreateLocalhost(ctx context.Context) ([]model.Site, error)
- func (s *DefaultSeeder) InternalCreatePage(ctx context.Context, site model.Site) error
- type DefaultSiteSelector
- func (s *DefaultSiteSelector) HostByLocaleRetrieve(r *http.Request, fallbackLocale string) (*model.Site, string, error)
- func (s *DefaultSiteSelector) HostPathByLocaleRetrieve(r *http.Request, fallbackLocale string) (*model.Site, string, error)
- func (s *DefaultSiteSelector) HostPathRetrieve(r *http.Request, fallbackLocale string) (*model.Site, string, error)
- func (s *DefaultSiteSelector) HostRetrieve(r *http.Request, fallbackLocale string) (*model.Site, string, error)
- func (s *DefaultSiteSelector) Retrieve(r *http.Request) (*model.Site, string, error)
- type ErrorHandler
- type ErrorResolverFunc
- type Matcher
- type Menu
- type PageCreateHandler
- type PageCreateRequest
- type PageHandler
- type RedirectError
- type Renderer
- type Seeder
- type SiteSelector
- type TwoFAAssertion
- type URLVoter
- type Validator
- type Voter
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInternal = errors.New("internal server error")
Functions ¶
func APIAuthorizer ¶ added in v0.0.9
func APIAuthorizer(authorizer echox.Authorizer) api.Authorizer
func Authorizer ¶ added in v0.0.9
func Authorizer(authorizer rbac.Authorizer) echox.Authorizer
func BasicAuthValidator ¶
func BasicAuthValidator(repo repository.Admin, logger *zap.Logger) middleware.BasicAuthValidator
func IsTextHTML ¶
func JWTAuthValidator ¶
func JWTAuthValidator(repo repository.Admin, secret string) middleware.KeyAuthValidator
func PageDecorate ¶
func PageDecorate(w http.ResponseWriter) bool
func PageNotDecorate ¶
func PageNotDecorate(w http.ResponseWriter) bool
func ParseUnverifiedJWT ¶
ParseUnverifiedJWT parses JWT and returns its claims but DOES NOT verify the signature.
It verifies only the exp, iat and nbf claims.
func RandomString ¶
func SkipSelectPage ¶
func SkipSelectSite ¶
func WithPageDecorate ¶
func WithPageDecorate(w http.ResponseWriter, value string)
Types ¶
type AdminService ¶
type AdminService struct {
// contains filtered or unexported fields
}
func NewAdminService ¶
func NewAdminService(repo repository.Admin) *AdminService
func (*AdminService) ChangePassword ¶
func (s *AdminService) ChangePassword(ctx context.Context, email, password string) error
func (*AdminService) ChangeRoles ¶
type DefaultMatcher ¶
type DefaultMatcher struct {
// contains filtered or unexported fields
}
func NewDefaultMatcher ¶
func NewDefaultMatcher(voters ...Voter) DefaultMatcher
func (DefaultMatcher) IsAncestor ¶
type DefaultMenu ¶
type DefaultMenu struct {
// contains filtered or unexported fields
}
func NewDefaultMenu ¶
func NewDefaultMenu(menuRepo repository.Menu, nodeRepo repository.Node) *DefaultMenu
type DefaultPageHandler ¶
type DefaultPageHandler struct{}
func NewDefaultPageHandler ¶
func NewDefaultPageHandler() *DefaultPageHandler
func (*DefaultPageHandler) Handle ¶
func (h *DefaultPageHandler) Handle(c echo.Context) error
type DefaultSeeder ¶
type DefaultSeeder struct {
// contains filtered or unexported fields
}
func NewDefaultSeeder ¶
func NewDefaultSeeder(siteRepository repository.Site, pageRepository repository.Page, logger *zap.Logger) *DefaultSeeder
func (*DefaultSeeder) CreateErrorPages ¶
func (*DefaultSeeder) FindOrCreateLocalhost ¶
func (*DefaultSeeder) InternalCreatePage ¶
type DefaultSiteSelector ¶
type DefaultSiteSelector struct {
// contains filtered or unexported fields
}
func NewDefaultSiteSelector ¶
func NewDefaultSiteSelector(cfgRepository repository.Configuration, siteRepository repository.Site) *DefaultSiteSelector
func (*DefaultSiteSelector) HostByLocaleRetrieve ¶
func (*DefaultSiteSelector) HostPathByLocaleRetrieve ¶
func (*DefaultSiteSelector) HostPathRetrieve ¶
func (*DefaultSiteSelector) HostRetrieve ¶
type ErrorHandler ¶
type ErrorHandler struct { Logger *zap.Logger Resolver ErrorResolverFunc SiteSelector SiteSelector PageHandler PageHandler PageRepository repository.Page CfgRepository repository.Configuration }
func NewErrorHandler ¶
func NewErrorHandler( pageHandler PageHandler, resolver ErrorResolverFunc, siteSelector SiteSelector, pageRepository repository.Page, cfgRepository repository.Configuration, logger *zap.Logger, ) *ErrorHandler
func (*ErrorHandler) Handle ¶
func (h *ErrorHandler) Handle(err error, c echo.Context)
type ErrorResolverFunc ¶
func ErrorResolver ¶
func ErrorResolver(asHTTPError func(err error, target **echo.HTTPError)) ErrorResolverFunc
type Matcher ¶
type Matcher interface { // IsCurrent checks whether a node is current IsCurrent(ctx context.Context, node *model.Node) bool // IsAncestor checks whether a node is the ancestor of a current node IsAncestor(ctx context.Context, node *model.Node) bool }
Matcher represents an interface for matching nodes. It provides methods for checking whether a node is current or an ancestor.
type PageCreateHandler ¶
type PageCreateHandler struct {
// contains filtered or unexported fields
}
func NewPageCreateHandler ¶
func NewPageCreateHandler(validator Validator, pageRepo repository.Page) *PageCreateHandler
func (*PageCreateHandler) Handle ¶
func (h *PageCreateHandler) Handle(c echo.Context) error
type PageCreateRequest ¶
type PageCreateRequest struct { SiteID int64 `json:"site_id,omitempty" form:"site_id,omitempty" validate:"required"` URL string `json:"url,omitempty" form:"url,omitempty" validate:"required"` Template string `json:"template,omitempty" form:"template,omitempty" validate:"required"` Title string `json:"title,omitempty" form:"title,omitempty" validate:"max=254"` }
type PageHandler ¶
type PageHandler interface {
Handle(echo.Context) error
}
type RedirectError ¶
func (RedirectError) Error ¶
func (r RedirectError) Error() string
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
func NewRenderer ¶
func NewRenderer(theme theme.Theme, cfgRepo repository.Configuration) *Renderer
type SiteSelector ¶
type TwoFAAssertion ¶
type TwoFAAssertion struct{}
type Voter ¶
type Voter interface { // MatchNode checks whether a node is current. // // If the voter is not able to determine a result, // it should return nil to let other voters do the job. MatchNode(ctx context.Context, node *model.Node) *bool }
Voter represents an interface for determining whether a node is current.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.