core

package module
v0.0.0-...-5127ed8 Latest Latest
Warning

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

Go to latest
Published: May 30, 2022 License: MIT Imports: 49 Imported by: 39

README

QOR

English Chat Room:

中文聊天室:

Build Status

For security issues, please send us an email to security@getqor.com and give us time to respond BEFORE posting as an issue or reporting on public forums.

What is QOR?

QOR is a set of libraries written in Go that abstracts common features needed for business applications, CMSs, and E-commerce systems.

This is a complete rewrite in Go, of the original QOR, which was a proprietary framework written in Ruby on Rails and used internally at The Plant. QOR 1.0 is the first version to be open sourced and distributed under the MIT license.

What QOR is not

QOR is not a "boxed turnkey solution". You need proper coding skills to use it. It's designed to make the lives of developers easier when building complex EC systems, not providing you one out of the box.

Documentation

https://doc.getqor.com/

The modules

  • Admin - The core part of QOR system, will generate an admin interface and RESTFul API for you to manage your data

  • Publish - Providing a staging environment for all content changes to be reviewed before being published to the live system

  • Transition - A configurable State Machine: define states, events (eg. pay order), and validation constraints for state transitions

  • Media Library - Asset Management with support for several cloud storage backends and publishing via a CDN

  • Worker (Batch processing) - A process scheduler

  • Exchange - Data exchange with other business applications using CSV or Excel data

  • Internationalization (i18n) - Managing and (inline) editing of translations

  • Localization (l10n) - Manage DB-backed models on per-locale basis, with support for defining/editing localizable attributes, and locale-based querying

  • Roles - Access Control

  • And more https://github.com/qor

Live DEMO

Frontend Development

Requires Node.js and Gulp for building frontend files

npm install && npm install -g gulp
  • Watch SCSS/JavaScript changes: gulp
  • Build Release files: gulp release

License

Released under the MIT License.

Documentation

Index

Constants

View Source
const (
	// ErrCantBeBlank cant blank field
	ErrCantBeBlank      err = "cant be blank"
	ErrCantBeBlankOneOf err = "cant be blank one of"
)
View Source
const PATH_MEDIA = "/!media"

Variables

View Source
var (
	StopSiteIteration = errors.New("stop site iteration")
	StopDBIteration   = errors.New("stop db iteration")
)
View Source
var (
	ErrDuplicateSiteHost = errors.New("duplicate site host")
	ErrDuplicateSitePath = errors.New("duplicate site path")
	ErrSiteNotFound      = errors.New("site not found")
	ErrSiteFound         = errors.New("site found")
)
View Source
var CONTEXT_KEY = PREFIX
View Source
var DefaultLang = "pt"
View Source
var (
	DefaultLocale string
)
View Source
var ErrStopIteration = errors.New("stop iteration")
View Source
var Globals = map[interface{}]interface{}{}
View Source
var PREFIX = path_helpers.GetCalledDir()
View Source
var PrepareRawDBContext = DefaultPrepareRawDBContext

Functions

func ContextHandle

func ContextHandle(w http.ResponseWriter, r *http.Request, handler ContextHandler)

func ContextToRequest

func ContextToRequest(req *http.Request, ctx *Context) *http.Request

func DefaultPrepareRawDBContext

func DefaultPrepareRawDBContext(db *DB) context.Context

func HTTPHandlerOf

func HTTPHandlerOf(handler ContextHandler) http.Handler

func MapstructureRawGetter2InterfaceGetter

func MapstructureRawGetter2InterfaceGetter(getter getters.Getter, errorcb func(key, value, dest interface{}, err error)) *getters.InterfaceGetterImpl

func SiteMediaHandler

func SiteMediaHandler(ctx *Context)

func StringifyError

func StringifyError(err error) string

func StringifyErrorT

func StringifyErrorT(ctx i18nmod.Context, err error) string

Types

type BreadCrumberFunc func(ctx *Context) ([]Breadcrumb, error)
func (f BreadCrumberFunc) Breadcrumbs(ctx *Context) ([]Breadcrumb, error)
type Breadcrumb interface {
	URI(context *Context) string
	Icon() string
	Label() string
}
type BreadcrumbProxy struct {
	// contains filtered or unexported fields
}

func NewBreadcrumb

func NewBreadcrumb(uri, label string, icon ...string) *BreadcrumbProxy
func (b BreadcrumbProxy) Icon() string
func (b BreadcrumbProxy) Label() string
func (b BreadcrumbProxy) URI(*Context) string
type Breadcrumber interface {
	Breadcrumbs(ctx *Context) (crumbs []Breadcrumb, err error)
}
type Breadcrumbs struct {
	Items []Breadcrumb
	// contains filtered or unexported fields
}
func (b *Breadcrumbs) AfterNext(breadcrumbs ...Breadcrumb)
func (b *Breadcrumbs) Append(breadcrumbs ...Breadcrumb)
func (b *Breadcrumbs) IsEmpty() bool
func (b *Breadcrumbs) ItemsWithoutLast() (items []Breadcrumb)
func (b *Breadcrumbs) Last() Breadcrumb

type ConfigGetter

type ConfigGetter interface {
	getters.Getter
	GetInterface(key, dest interface{}) (ok bool)
}

type ConfigSetter

type ConfigSetter interface {
	Set(key interface{}, value interface{}) (err error)
	Destroy()
}

type ConfigSetterFunc

type ConfigSetterFunc func(key interface{}, value interface{}) (err error)

func (ConfigSetterFunc) Set

func (this ConfigSetterFunc) Set(key interface{}, value interface{}) (err error)

type Configor

type Configor interface {
	ConfigSet(key, value interface{})
	ConfigGet(key interface{}) (value interface{}, ok bool)
}

type Configors

type Configors []Configor

func (Configors) ConfigGet

func (c Configors) ConfigGet(key interface{}) (value interface{}, ok bool)

func (Configors) ConfigSet

func (c Configors) ConfigSet(key, value interface{})

type Context

type Context struct {
	LocalContext
	Errors

	Parent *Context

	Request    *http.Request
	Writer     httpu.ResponseWriter
	Roles      roles.Roles
	ResourceID aorm.ID

	ParentResourceID,
	ExcludeResourceID []aorm.ID

	Config        *site_config.Config
	I18nContext   i18nmod.Context
	DefaultLocale string
	Locale        string

	Prefix    string
	StaticURL string

	Site        *Site
	OriginalURL *url.URL

	RouteContext   *xroute.RouteContext
	Translator     *i18nmod.Translator
	ContextFactory *ContextFactory
	I18nGroupStack *i18nGroup
	Role           *roles.Role
	Lang           string
	LangTag        *language.Tag
	NotFound       bool
	Api            bool

	RedirectTo    string
	MetaTreeStack *NameStacker

	DecoderExcludes *DecoderExcludes

	MetaContextFactory func(parent *Context, res interface{}, record interface{}) *Context
	FormOptions        FormOptions
	// contains filtered or unexported fields
}

Context qor context, which is used for many qor components, used to share information between them

func ContextFromDB

func ContextFromDB(db *aorm.DB) *Context

func ContextFromRequest

func ContextFromRequest(req *http.Request) (ctx *Context)

func NewContext

func NewContext(arg ...*Context) (ctx *Context)

func (*Context) Anonymous

func (this *Context) Anonymous() bool

func (*Context) AsTop

func (this *Context) AsTop() *Context

func (*Context) Breadcrumbs

func (this *Context) Breadcrumbs() *Breadcrumbs

func (*Context) Clone

func (this *Context) Clone() *Context

Clone clone current context

func (*Context) CloneBasic

func (this *Context) CloneBasic() *Context

Clone clone current context

func (*Context) CurrentUser

func (this *Context) CurrentUser() common.User

func (*Context) DB

func (this *Context) DB(db ...*aorm.DB) *aorm.DB

func (*Context) DefaultMediaURL

func (this *Context) DefaultMediaURL(name string, pth ...string) string

func (*Context) DefaultStorageEndpoint

func (this *Context) DefaultStorageEndpoint() (url string)

func (*Context) DelValue

func (this *Context) DelValue(key interface{}) *Context

func (*Context) Err

func (this *Context) Err() error

func (*Context) ErrorResult

func (this *Context) ErrorResult() Result

func (*Context) ErrorT

func (this *Context) ErrorT(err error) error

func (*Context) ErrorTS

func (this *Context) ErrorTS(err error) string

func (*Context) Flag

func (this *Context) Flag(key interface{}) bool

func (*Context) FlashT

func (this *Context) FlashT(msg interface{}, typ string) (err error)

func (*Context) FlashTOrError

func (this *Context) FlashTOrError(msg interface{}, typ string) (ok bool)

func (*Context) Get

func (this *Context) Get(key interface{}) (interface{}, bool)

func (*Context) GetCleanFormattedErrors

func (this *Context) GetCleanFormattedErrors() (formatedErrors []FormattedError)

func (*Context) GetCleanFormattedErrorsOf

func (this *Context) GetCleanFormattedErrorsOf(errs *Errors) (formatedErrors []FormattedError)

func (*Context) GetErrorsT

func (this *Context) GetErrorsT() []error

func (*Context) GetErrorsTS

func (this *Context) GetErrorsTS() []string

func (*Context) GetFormOrQuery

func (this *Context) GetFormOrQuery(key string) (value string)

func (*Context) GetFormattedErrors

func (this *Context) GetFormattedErrors() (formatedErrors []FormattedError)

func (*Context) GetFormattedErrorsOf

func (this *Context) GetFormattedErrorsOf(errs *Errors) (formatedErrors []FormattedError)

func (*Context) GetI18nContext

func (this *Context) GetI18nContext() i18nmod.Context

func (*Context) GetLocale

func (this *Context) GetLocale() string

func (*Context) GetOrDefault

func (this *Context) GetOrDefault(key, defaul interface{}) interface{}

func (*Context) GetStaticURL

func (this *Context) GetStaticURL() string

func (*Context) GetValue

func (this *Context) GetValue(key interface{}) interface{}

func (*Context) Htmlify

func (this *Context) Htmlify(value interface{}) template.HTML

func (*Context) I18nT

func (this *Context) I18nT(key string) *i18nmod.T

func (*Context) IsTop

func (this *Context) IsTop() bool

func (*Context) JoinCurrentURL

func (this *Context) JoinCurrentURL(params ...interface{}) (joinedURL string, err error)

JoinCurrentURL is a convinent wrapper for qor/utils.JoinURL

func (*Context) JoinPath

func (this *Context) JoinPath(path ...string) string

func (*Context) JoinStaticURL

func (this *Context) JoinStaticURL(path ...string) string

func (*Context) JoinURL

func (this *Context) JoinURL(url string, params ...interface{}) (joinedURL string, err error)

JoinURL is a convinent wrapper for qor/utils.JoinURL

func (*Context) Logger

func (this *Context) Logger() logging.Logger

func (*Context) MediaURL

func (this *Context) MediaURL(storageName, name string, pth ...string) string

func (*Context) NewChild

func (this *Context) NewChild(r *http.Request, prefix ...string) (*http.Request, *Context)

func (*Context) Now

func (this *Context) Now() time.Time

func (*Context) PatchCurrentURL

func (this *Context) PatchCurrentURL(params ...interface{}) (patchedURL string, err error)

PatchCurrentURL is a convinent wrapper for qor/utils.PatchURL

func (*Context) PatchURL

func (this *Context) PatchURL(url string, params ...interface{}) (patchedURL string, err error)

PatchURL is a convinent wrapper for qor/utils.PatchURL

func (*Context) Path

func (this *Context) Path(path ...string) string

func (*Context) PopI18nGroup

func (this *Context) PopI18nGroup()

func (*Context) PushI18nGroup

func (this *Context) PushI18nGroup(group string) func()

func (*Context) Read

func (this *Context) Read(p []byte) (n int, err error)

func (*Context) RequestPath

func (this *Context) RequestPath() string

func (*Context) RequestTime

func (this *Context) RequestTime() time.Time

func (*Context) Root

func (this *Context) Root() *Context

func (*Context) SessionManager

func (this *Context) SessionManager() session.RequestSessionManager

func (*Context) SetCurrentUser

func (this *Context) SetCurrentUser(user common.User)

func (*Context) SetDB

func (this *Context) SetDB(db *aorm.DB) *Context

func (*Context) SetRawDB

func (this *Context) SetRawDB(db *aorm.DB) *Context

func (*Context) SetRequest

func (this *Context) SetRequest(r *http.Request)

func (*Context) SetRequestTime

func (this *Context) SetRequestTime(requestTime time.Time)

func (*Context) SetSessionManager

func (this *Context) SetSessionManager(manager session.RequestSessionManager) *Context

func (*Context) SetTimeLocation

func (this *Context) SetTimeLocation(timeLocation *time.Location)

func (*Context) SetValue

func (this *Context) SetValue(key, value interface{}) *Context

func (*Context) StorageEndpoint

func (this *Context) StorageEndpoint(storageName string) (url string)

func (*Context) T

func (this *Context) T(key string, defaul ...interface{}) template.HTML

func (*Context) TT

func (this *Context) TT(key string, data interface{}, defaul ...interface{}) template.HTML

func (*Context) TTs

func (this *Context) TTs(key string, data interface{}, defaul ...interface{}) string

func (*Context) TimeLocation

func (this *Context) TimeLocation() *time.Location

func (*Context) Top

func (this *Context) Top() *Context

func (*Context) Ts

func (this *Context) Ts(key string, defaul ...interface{}) string

func (*Context) Tt

func (this *Context) Tt(o I18nLabelPair) (r template.HTML)

func (*Context) TtS

func (this *Context) TtS(o I18nLabelPair) (r string)

func (*Context) URL

func (this *Context) URL(pth ...string) string

func (*Context) URLParam

func (this *Context) URLParam(key string) string

func (*Context) URLParams

func (this *Context) URLParams() *xroute.OrderedMap

func (*Context) UserID

func (this *Context) UserID() aorm.ID

func (*Context) Value

func (this *Context) Value(key interface{}) interface{}

func (Context) WithContext

func (this Context) WithContext(ctx context.Context) *Context

func (Context) WithDB

func (this Context) WithDB(f func(ctx *Context), db ...*aorm.DB) *Context

func (*Context) Write

func (this *Context) Write(p []byte) (n int, err error)

func (*Context) WsURL

func (this *Context) WsURL(pth ...string) string

type ContextFactory

type ContextFactory struct {
	Translator *i18nmod.Translator
	// contains filtered or unexported fields
}

func NewContextFactory

func NewContextFactory(translator *i18nmod.Translator) *ContextFactory

func (*ContextFactory) AfterCreate

func (cf *ContextFactory) AfterCreate(f ...func(ctx *Context))

func (*ContextFactory) GetOrNewContextFromRequestPair

func (cf *ContextFactory) GetOrNewContextFromRequestPair(w http.ResponseWriter, r *http.Request) (*http.Request, *Context)

func (*ContextFactory) NewContextForRequest

func (cf *ContextFactory) NewContextForRequest(req *http.Request, prefix ...string) (*http.Request, *Context)

func (*ContextFactory) NewContextFromRequestPair

func (cf *ContextFactory) NewContextFromRequestPair(w http.ResponseWriter, r *http.Request, prefix ...string) (*http.Request, *Context)

func (*ContextFactory) NewSiteContext

func (cf *ContextFactory) NewSiteContext(site *Site) *Context

type ContextGetter

type ContextGetter interface {
	GetContext() *Context
}

type ContextHandler

type ContextHandler interface {
	ContextHandle(ctx *Context)
}

type ContextHandlerFunc

type ContextHandlerFunc func(ctx *Context)

func (ContextHandlerFunc) ContextHandle

func (this ContextHandlerFunc) ContextHandle(ctx *Context)

type ContextPermissioner

type ContextPermissioner interface {
	HasContextPermission(mode roles.PermissionMode, ctx *Context) (perm roles.Perm)
}

type ContextProxy

type ContextProxy struct {
	Getter func() context.Context
}

func (*ContextProxy) Deadline

func (this *ContextProxy) Deadline() (deadline time.Time, ok bool)

func (*ContextProxy) Done

func (this *ContextProxy) Done() <-chan struct{}

func (*ContextProxy) Err

func (this *ContextProxy) Err() error

func (*ContextProxy) Get

func (this *ContextProxy) Get(key interface{}) (value interface{}, ok bool)

func (*ContextProxy) Value

func (this *ContextProxy) Value(key interface{}) (value interface{})

type ContextStringer

type ContextStringer interface {
	ContextString(ctx *Context) string
}

type Contexts

type Contexts []context.Context

func (Contexts) Append

func (this Contexts) Append(ctx ...context.Context) Contexts

func (Contexts) Deadline

func (this Contexts) Deadline() (deadline time.Time, ok bool)

func (Contexts) Done

func (this Contexts) Done() (done <-chan struct{})

func (Contexts) Err

func (this Contexts) Err() (err error)

func (Contexts) Prepend

func (this Contexts) Prepend(ctx ...context.Context) Contexts

func (Contexts) Value

func (this Contexts) Value(key interface{}) (value interface{})

type CookiStoreFactory

type CookiStoreFactory func(context *Context, options *sessions.Options, codecs *CookieCodec) *sessions.CookieStore

type CookieCodec

type CookieCodec struct {
	Codecs []securecookie.Codec
}

type DB

type DB struct {
	Site   *Site
	Config *dbconfig.DBConfig
	Name   string
	DB     *aorm.DB
	// contains filtered or unexported fields
}

func GetDBFromDB

func GetDBFromDB(db *aorm.DB) *DB

func (*DB) Close

func (db *DB) Close() (err error)

func (*DB) InitCallback

func (db *DB) InitCallback(cb ...func(DB *DB))

func (*DB) Open

func (db *DB) Open(ctx context.Context) (err error)

func (*DB) ReOpen

func (db *DB) ReOpen(ctx context.Context) (err error)

type DecoderExclude

type DecoderExclude struct {
	ID   aorm.ID
	Path string
	Data interface{}
}

type DecoderExcludes

type DecoderExcludes struct {
	Excludes []DecoderExclude
}

func (*DecoderExcludes) Add

func (this *DecoderExcludes) Add(id aorm.ID, pth string, data interface{})

func (*DecoderExcludes) HasItemOf

func (this *DecoderExcludes) HasItemOf(path string) bool

type DefaultConfigSetter

type DefaultConfigSetter struct {
	SetterFunc  func(key interface{}, value interface{}) (err error)
	DestroyFunc func()
}

func (*DefaultConfigSetter) Destroy

func (this *DefaultConfigSetter) Destroy()

func (*DefaultConfigSetter) Set

func (this *DefaultConfigSetter) Set(key interface{}, value interface{}) (err error)

type DefaultPermissionDenier

type DefaultPermissionDenier interface {
	DefaultPermissionDeny() bool
}

type Errors

type Errors []error

Errors is a struct that used to hold errors array

func NewErrors

func NewErrors(e ...error) (errors *Errors)

func (*Errors) AddError

func (errs *Errors) AddError(errors ...error) error

AddError add error to Errors struct

func (Errors) Error

func (errs Errors) Error() string

error get formatted error message

func (Errors) Filter

func (errs Errors) Filter(matcher func(err error) error) Errors

ExcludeError exclude errors when match matcher and returns new Errors with not mached errors

func (Errors) GetErrors

func (errs Errors) GetErrors() []error

GetErrors return error array

func (Errors) GetErrorsT

func (errs Errors) GetErrorsT(ctx i18nmod.Context) (l []error)

func (Errors) GetErrorsTS

func (errs Errors) GetErrorsTS(ctx i18nmod.Context) (strs []string)

func (Errors) HasError

func (errs Errors) HasError() bool

HasError return has error or not

func (Errors) Len

func (errs Errors) Len() int

func (*Errors) Reset

func (errs *Errors) Reset()

func (Errors) String

func (errs Errors) String() string

func (Errors) StringT

func (errs Errors) StringT(ctx i18nmod.Context) string

type FormOptions

type FormOptions struct {
	InputPrefix               string
	DefaultValueFixerDisabled bool
}

type FormattedError

type FormattedError struct {
	Label  string
	Errors []string
}

type I18nLabelPair

type I18nLabelPair interface {
	GetLabelPair() (keys []string, defaul string)
}

type LocalContext

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

func (*LocalContext) BackupValues

func (this *LocalContext) BackupValues() func()

func (LocalContext) Copy

func (this LocalContext) Copy() *LocalContext

func (*LocalContext) Deadline

func (this *LocalContext) Deadline() (deadline time.Time, ok bool)

func (*LocalContext) Done

func (this *LocalContext) Done() <-chan struct{}

func (*LocalContext) Err

func (this *LocalContext) Err() error

func (*LocalContext) Get

func (this *LocalContext) Get(key interface{}) (value interface{}, ok bool)

func (*LocalContext) GetContext

func (this *LocalContext) GetContext() context.Context

func (*LocalContext) SetContext

func (this *LocalContext) SetContext(ctx context.Context)

func (*LocalContext) SetValue

func (this *LocalContext) SetValue(key, value interface{}) *LocalContext

func (*LocalContext) SetValues

func (this *LocalContext) SetValues(key, value interface{}, pairs ...interface{}) *LocalContext

func (*LocalContext) Value

func (this *LocalContext) Value(key interface{}) (value interface{})

func (LocalContext) WithContext

func (this LocalContext) WithContext(ctx context.Context) *LocalContext

type MultipleSiteGetter

type MultipleSiteGetter []SiteGetter

func (*MultipleSiteGetter) Append

func (this *MultipleSiteGetter) Append(g ...SiteGetter) *MultipleSiteGetter

func (MultipleSiteGetter) Get

func (this MultipleSiteGetter) Get(site *Site, key interface{}) (value interface{}, ok bool)

func (MultipleSiteGetter) GetInterface

func (this MultipleSiteGetter) GetInterface(site *Site, key, dest interface{}) (ok bool)

func (*MultipleSiteGetter) Prepend

func (this *MultipleSiteGetter) Prepend(g ...SiteGetter) *MultipleSiteGetter

type NameFrame

type NameFrame struct {
	Key   string
	Name  string
	Namer func() string
	Index int
}

type NameStack

type NameStack []NameFrame

func (NameStack) JoinOptions

func (this NameStack) JoinOptions(sep string, indexFormat func(index int) string) string

func (*NameStack) WithIndex

func (this *NameStack) WithIndex(index int, key ...string) func()

func (*NameStack) WithName

func (this *NameStack) WithName(name string, key ...string) func()

func (*NameStack) WithNamer

func (this *NameStack) WithNamer(f func() string, key ...string) func()

type NameStacker

type NameStacker struct {
	Stack       NameStack
	Sep         string
	IndexFormat func(index int) string
}

func (NameStacker) String

func (this NameStacker) String() string

func (*NameStacker) WithIndex

func (this *NameStacker) WithIndex(index int, key ...string) func()

func (*NameStacker) WithName

func (this *NameStacker) WithName(name string, key ...string) func()

func (*NameStacker) WithNamer

func (this *NameStacker) WithNamer(f func() string, key ...string) func()

type NamedContextHandler

type NamedContextHandler struct {
	Name    string
	Handler func(ctx *Context)
}

func GetNamedContextHandlers

func GetNamedContextHandlers(this NamedContextHandlersRegistrator) (handlers []*NamedContextHandler, err error)

func MustGetNamedContextHandlers

func MustGetNamedContextHandlers(this NamedContextHandlersRegistrator) (handlers []*NamedContextHandler, err error)

type NamedContextHandlersRegistrator

type NamedContextHandlersRegistrator interface {
	InheritsFrom(registrator ...NamedContextHandlersRegistrator)
	Add(handler ...*NamedContextHandler)
	Get(name string) *NamedContextHandler
	Each(cb func(handler *NamedContextHandler) (err error), state ...map[string]*NamedContextHandler) (err error)
}

type NamedContextHandlersRegistry

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

func (*NamedContextHandlersRegistry) Add

func (this *NamedContextHandlersRegistry) Add(handler ...*NamedContextHandler)

func (*NamedContextHandlersRegistry) Each

func (this *NamedContextHandlersRegistry) Each(cb func(handler *NamedContextHandler) (err error), state ...map[string]*NamedContextHandler) (err error)

func (*NamedContextHandlersRegistry) Get

func (*NamedContextHandlersRegistry) InheritsFrom

func (this *NamedContextHandlersRegistry) InheritsFrom(registrator ...NamedContextHandlersRegistrator)

type Option

type Option interface {
	Apply(configor Configor)
}

type OptionFunc

type OptionFunc func(configor Configor)

func (OptionFunc) Apply

func (this OptionFunc) Apply(configor Configor)

type PermissionModeProvider

type PermissionModeProvider interface {
	Provides() roles.Roles
}

type Permissioner

type Permissioner interface {
	HasPermission(mode roles.PermissionMode, ctx *Context) roles.Perm
}

func AllowedPermissioners

func AllowedPermissioners(p ...Permissioner) Permissioner

func NewPermissioner

func NewPermissioner(f func(mode roles.PermissionMode, ctx *Context) (perm roles.Perm)) Permissioner

func Permissioners

func Permissioners(p ...Permissioner) Permissioner

func RolePermissioner

func RolePermissioner(permissioner roles.Permissioner) Permissioner

type PermissionerFunc

type PermissionerFunc func(mode roles.PermissionMode, ctx *Context) roles.Perm

func (PermissionerFunc) HasPermission

func (f PermissionerFunc) HasPermission(mode roles.PermissionMode, ctx *Context) roles.Perm

type RawDB

type RawDB struct {
	DB *DB
	// contains filtered or unexported fields
}

func (*RawDB) Close

func (r *RawDB) Close()

func (*RawDB) Do

func (r *RawDB) Do(f func(con db.RawDBConnection))

func (*RawDB) Open

func (r *RawDB) Open(ctx context.Context) (conn db.RawDBConnection, err error)

type RawDBConnectError

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

func (*RawDBConnectError) Error

func (r *RawDBConnectError) Error() string

type RecordPermissioner

type RecordPermissioner interface {
	HasRecordPermission(mode roles.PermissionMode, ctx *Context, record interface{}) (perm roles.Perm)
}

func NewRecordPermissioner

func NewRecordPermissioner(f func(mode roles.PermissionMode, ctx *Context, record interface{}) (perm roles.Perm)) RecordPermissioner

type RecordPermissionerFunc

type RecordPermissionerFunc func(mode roles.PermissionMode, ctx *Context, record interface{}) roles.Perm

func (RecordPermissionerFunc) HasRecordPermission

func (f RecordPermissionerFunc) HasRecordPermission(mode roles.PermissionMode, ctx *Context, record interface{}) roles.Perm

type Result

type Result struct {
	Messages []string `json:"messages;omitempty"`
	Type     string   `json:"type;omitempty"`
	Code     int      `json:"code;omitempty"`
}

type SentWriterInterface

type SentWriterInterface interface {
	http.ResponseWriter
	Sent() bool
}

type SetupConfig

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

func Setup

func Setup(options SetupOptions) *SetupConfig

func (*SetupConfig) CookieStoreFactory

func (c *SetupConfig) CookieStoreFactory() CookiStoreFactory

func (*SetupConfig) Home

func (c *SetupConfig) Home() string

func (*SetupConfig) IsDev

func (c *SetupConfig) IsDev() bool

func (*SetupConfig) IsProduction

func (c *SetupConfig) IsProduction() bool

func (*SetupConfig) Root

func (c *SetupConfig) Root() string

func (*SetupConfig) TempDir

func (c *SetupConfig) TempDir() string

type SetupDB

type SetupDB func(setup func(db *DB) error) (err error)

type SetupOptions

type SetupOptions struct {
	Home               string
	Root               string
	TempDir            string
	Production         bool
	CookieStoreFactory CookiStoreFactory
	CookieMaxAge       int
	CookieCodecs       []securecookie.Codec
}

type Severity

type Severity int

Severity is the severity of the event described in a log entry. These guideline severity levels are ordered, with numerically smaller levels treated as less severe than numerically larger levels.

const (
	// Default means the log entry has no assigned severity level.
	Default Severity = iota
	// Debug means debug or trace information.
	Debug
	// Info means routine information, such as ongoing status or performance.
	Info
	// Notice means normal but significant events, such as start up, shut down, or configuration.
	Notice
	// Warning means events that might cause problems.
	Warning
	// Error means events that are likely to cause problems.
	Error
	// Critical means events that cause more severe problems or brief outages.
	Critical
	// Alert means a person must take an action immediately.
	Alert
	// Emergency means one or more systems are unusable.
	Emergency
)

func ParseSeverity

func ParseSeverity(s string) Severity

ParseSeverity returns the Severity whose name equals s, ignoring case. It returns Default if no Severity matches.

func SignToSeverity

func SignToSeverity(v int) Severity

func (*Severity) Parse

func (v *Severity) Parse(s string)

Parse parse Severity whose name equals s, ignoring case. It sets Default if no Severity matches.

func (Severity) String

func (v Severity) String() string

String converts a severity level to a string.

type Site

type Site struct {
	Dbs map[string]*DB

	Data        maps.Map
	Middlewares xroute.Middlewares

	Log                    logging.Logger
	PermissionModeProvider PermissionModeProvider

	Mux *xroute.Mux
	// contains filtered or unexported fields
}

func GetSiteFromDB

func GetSiteFromDB(db *aorm.DB) *Site

func GetSiteFromRequest

func GetSiteFromRequest(r *http.Request) *Site

func NewSite

func NewSite(name string, basicConfig site_config.Config, configGetter getters.InterfaceGetter, cf *ContextFactory) *Site

func (*Site) BasicConfig

func (this *Site) BasicConfig() *site_config.Config

func (*Site) BuildHandler

func (this *Site) BuildHandler(parent *xroute.Mux) xroute.ContextHandler

func (*Site) Config

func (this *Site) Config() SiteConfig

func (*Site) ConfigSetter

func (this *Site) ConfigSetter() ConfigSetter

func (*Site) EachDB

func (this *Site) EachDB(f func(db *DB) error) (err error)

func (*Site) GetConfig

func (this *Site) GetConfig(key interface{}) (value interface{}, ok bool)

func (*Site) GetConfigInterface

func (this *Site) GetConfigInterface(key, dest interface{}) (ok bool)

func (*Site) GetDB

func (this *Site) GetDB(name string) *DB

func (*Site) GetDBOrSystem

func (this *Site) GetDBOrSystem(name string) *DB

func (*Site) GetDefaultMediaStorage

func (this *Site) GetDefaultMediaStorage() oss.NamedStorageInterface

func (*Site) GetMediaStorage

func (this *Site) GetMediaStorage(name string) oss.NamedStorageInterface

func (*Site) GetMediaStorageOrDefault

func (this *Site) GetMediaStorageOrDefault(name string) oss.NamedStorageInterface

func (*Site) GetSystemDB

func (this *Site) GetSystemDB() *DB

func (*Site) Handler

func (this *Site) Handler() xroute.ContextHandler

func (*Site) HandlerChanged

func (this *Site) HandlerChanged(f ...func(oldh, newh xroute.ContextHandler))

func (*Site) Init

func (this *Site) Init(opts *SiteInitOptions) (err error)

func (*Site) InitOrPanic

func (this *Site) InitOrPanic(opts *SiteInitOptions) *Site

func (*Site) IsRegistered

func (this *Site) IsRegistered() bool

func (*Site) MediaStorages

func (this *Site) MediaStorages() map[string]oss.NamedStorageInterface

func (*Site) MustConfig

func (this *Site) MustConfig(key interface{}) (value interface{})

func (*Site) Name

func (this *Site) Name() string

func (*Site) NewContext

func (this *Site) NewContext() *Context

func (*Site) OnDestroy

func (this *Site) OnDestroy(f ...func())

func (*Site) PostInit

func (this *Site) PostInit(f ...func())

func (*Site) PrepareContext

func (this *Site) PrepareContext(ctx *Context) *Context

func (*Site) PublicURL

func (this *Site) PublicURL(p ...string) string

func (*Site) PublicURLf

func (this *Site) PublicURLf(p ...interface{}) string

func (*Site) RequestLogger

func (this *Site) RequestLogger(key string) (fmtr middleware.LogAndPanicFormatter)

func (*Site) Role

func (this *Site) Role() *roles.Role

func (*Site) ServeHTTP

func (this *Site) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Site) ServeHTTPContext

func (this *Site) ServeHTTPContext(w http.ResponseWriter, r *http.Request, rctx *xroute.RouteContext)

func (*Site) SetConfig

func (this *Site) SetConfig(key string, value interface{}) (err error)

func (*Site) SetConfigSetter

func (this *Site) SetConfigSetter(configSetter ConfigSetter)

func (*Site) SetHandler

func (this *Site) SetHandler(handler xroute.ContextHandler)

func (*Site) StorageNames

func (this *Site) StorageNames() *oss.Names

func (*Site) SystemStorage

func (this *Site) SystemStorage() *filesystem.FileSystem

func (*Site) TextRender

func (this *Site) TextRender(v string) (s string, err error)

func (*Site) TimeLocation

func (this *Site) TimeLocation() *time.Location

func (*Site) Title

func (this *Site) Title() string

type SiteConfig

type SiteConfig interface {
	ConfigGetter
	ConfigSetter
}

type SiteConfigSetterFacotry

type SiteConfigSetterFacotry interface {
	Factory(site *Site) (setter ConfigSetter)
	FactoryCallback(cb ...*SiteFactoryCallback)
}

type SiteConfigType

type SiteConfigType uint8
const (
	SiteConfigBasic SiteConfigType = iota
	SiteConfigContextFactory

	SiteInitOptionsKey = "core:site_init_options"
)

type SiteFactoryCallback

type SiteFactoryCallback struct {
	Setup   func(site *Site, setter ConfigSetter)
	Destroy func(site *Site)
}

type SiteGetter

type SiteGetter interface {
	Get(site *Site, key interface{}) (value interface{}, ok bool)
	GetInterface(site *Site, key, dest interface{}) (ok bool)
}

func NewSiteGetter

func NewSiteGetter(getter func(site *Site, key interface{}) (value interface{}, ok bool), ifGetter func(site *Site, key, dest interface{}) (ok bool)) SiteGetter

type SiteGetterImpl

type SiteGetterImpl struct {
	GetFunc          func(site *Site, key interface{}) (value interface{}, ok bool)
	GetInterfaceFunc func(site *Site, key, dest interface{}) (ok bool)
}

func (*SiteGetterImpl) Get

func (f *SiteGetterImpl) Get(site *Site, key interface{}) (value interface{}, ok bool)

func (*SiteGetterImpl) GetInterface

func (f *SiteGetterImpl) GetInterface(site *Site, key, dest interface{}) (ok bool)

type SiteInitOptions

type SiteInitOptions struct {
	DBAutoConnectDisabled bool
}

type SitePermissionModeProvider

type SitePermissionModeProvider struct {
	Site    *Site
	Std     func() roles.Roles
	Default func() roles.Roles
}

func (SitePermissionModeProvider) Provides

func (this SitePermissionModeProvider) Provides() (modes roles.Roles)

type SitesMap

type SitesMap map[string]*Site

func (SitesMap) All

func (r SitesMap) All() (sites []*Site)

func (SitesMap) Copy

func (m SitesMap) Copy() (copy SitesMap)

func (*SitesMap) Del

func (m *SitesMap) Del(key string) (site *Site, err error)

func (SitesMap) Each

func (r SitesMap) Each(cb func(site *Site) (err error)) (err error)

func (SitesMap) EachOrAll

func (r SitesMap) EachOrAll(siteName string, cb func(site *Site) (err error)) error

func (SitesMap) Get

func (m SitesMap) Get(key string) (site *Site, ok bool)

func (SitesMap) GetOrError

func (r SitesMap) GetOrError(siteName string) (*Site, error)

func (SitesMap) Has

func (m SitesMap) Has(key ...string) (ok bool)

func (SitesMap) Keys

func (r SitesMap) Keys() (keys []string)

func (SitesMap) MustGet

func (m SitesMap) MustGet(key string) (site *Site)

func (SitesMap) Names

func (r SitesMap) Names() (names []string)

func (*SitesMap) Set

func (m *SitesMap) Set(key string, value *Site)

func (SitesMap) Sorted

func (r SitesMap) Sorted() []*Site

type SitesRegister

type SitesRegister struct {
	Alone                bool
	ByName               SitesMap
	ByHost               SitesMap
	ByPath               SitesMap
	AddedCallbacks       []func(site *Site)
	PostAddedCallbacks   []func(site *Site)
	DeletedCallbacks     []func(site *Site)
	HostAddedCallbacks   []func(site *Site, host string)
	HostDeletedCallbacks []func(site *Site, host string)
	PathAddedCallbacks   []func(site *Site, pth string)
	PathDeletedCallbacks []func(site *Site, pth string)
	SiteConfigGetter     MultipleSiteGetter
	// contains filtered or unexported fields
}

func (*SitesRegister) Add

func (this *SitesRegister) Add(site *Site) (err error)

func (*SitesRegister) AddHost

func (this *SitesRegister) AddHost(siteName, host string) error

func (*SitesRegister) AddPath

func (this *SitesRegister) AddPath(siteName, path string) error

func (*SitesRegister) DelHost

func (this *SitesRegister) DelHost(host string) error

func (*SitesRegister) DelPath

func (this *SitesRegister) DelPath(siteName, path string) error

func (*SitesRegister) Destroy

func (this *SitesRegister) Destroy() (err error)

func (*SitesRegister) DestroySite

func (this *SitesRegister) DestroySite(name ...string) (err error)

func (*SitesRegister) Get

func (this *SitesRegister) Get(name string) (site *Site, ok bool)

func (*SitesRegister) GetByHost

func (this *SitesRegister) GetByHost(host string) (site *Site, ok bool)

func (*SitesRegister) GetByPath

func (this *SitesRegister) GetByPath(path string) (site *Site, ok bool)

func (*SitesRegister) Has

func (this *SitesRegister) Has(name string) (ok bool)

func (*SitesRegister) HasSites

func (this *SitesRegister) HasSites() bool

func (*SitesRegister) MustGet

func (this *SitesRegister) MustGet(name string) (site *Site)

func (*SitesRegister) OnAdd

func (this *SitesRegister) OnAdd(f ...func(site *Site)) *SitesRegister

func (*SitesRegister) OnHostAdd

func (this *SitesRegister) OnHostAdd(f ...func(site *Site, host string)) *SitesRegister

func (*SitesRegister) OnHostDel

func (this *SitesRegister) OnHostDel(f ...func(site *Site, host string)) *SitesRegister

func (*SitesRegister) OnPathAdd

func (this *SitesRegister) OnPathAdd(f ...func(site *Site, path string)) *SitesRegister

func (*SitesRegister) OnPathDel

func (this *SitesRegister) OnPathDel(f ...func(site *Site, path string)) *SitesRegister

func (*SitesRegister) OnPostAdd

func (this *SitesRegister) OnPostAdd(f ...func(site *Site)) *SitesRegister

func (*SitesRegister) OnSetSiteConfigSetterFactory

func (this *SitesRegister) OnSetSiteConfigSetterFactory(cb ...func(cb SiteConfigSetterFacotry))

func (*SitesRegister) OnSiteDestroy

func (this *SitesRegister) OnSiteDestroy(f ...func(site *Site)) *SitesRegister

func (*SitesRegister) Only

func (this *SitesRegister) Only(name string, f func(site *Site) error) error

func (*SitesRegister) Reader

func (this *SitesRegister) Reader() SitesMap

func (*SitesRegister) Rename

func (this *SitesRegister) Rename(oldName, newName string) error

func (*SitesRegister) SetSiteConfigSetterFactory

func (this *SitesRegister) SetSiteConfigSetterFactory(siteConfigSetterFactory SiteConfigSetterFacotry)

func (*SitesRegister) SetSiteConfigSetterFactoryCallbacks

func (this *SitesRegister) SetSiteConfigSetterFactoryCallbacks(siteConfigSetterFactoryCallbacks []func(cb SiteConfigSetterFacotry))

func (*SitesRegister) Site

func (this *SitesRegister) Site() *Site

func (*SitesRegister) SiteConfigSetterFactory

func (this *SitesRegister) SiteConfigSetterFactory() SiteConfigSetterFacotry

func (*SitesRegister) SiteConfigSetterFactoryCallbacks

func (this *SitesRegister) SiteConfigSetterFactoryCallbacks() []func(cb SiteConfigSetterFacotry)

type StringSlice

type StringSlice []string

func (StringSlice) Has

func (this StringSlice) Has(v string) bool

func (StringSlice) Interfaces

func (this StringSlice) Interfaces() []interface{}

Directories

Path Synopsis
db
test
str
uri
url

Jump to

Keyboard shortcuts

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