Documentation ¶
Index ¶
- func Content(ctx interface{}, panel types.GetPanelFn)
- func Register(ada adapter.WebFrameWork)
- func User(ctx interface{}) (models.UserModel, bool)
- type ConnectionSetter
- type Engine
- func (eng *Engine) AddAdapter(ada adapter.WebFrameWork) *Engine
- func (eng *Engine) AddAuthService(processor auth.Processor) *Engine
- func (eng *Engine) AddConfig(cfg config.Config) *Engine
- func (eng *Engine) AddConfigFromINI(path string) *Engine
- func (eng *Engine) AddConfigFromJSON(path string) *Engine
- func (eng *Engine) AddConfigFromYAML(path string) *Engine
- func (eng *Engine) AddDisplayFilterLimit(limit int) *Engine
- func (eng *Engine) AddDisplayFilterSubstr(start int, end int) *Engine
- func (eng *Engine) AddDisplayFilterToLower() *Engine
- func (eng *Engine) AddDisplayFilterToTitle() *Engine
- func (eng *Engine) AddDisplayFilterToUpper() *Engine
- func (eng *Engine) AddDisplayFilterTrimSpace() *Engine
- func (eng *Engine) AddDisplayFilterXssFilter() *Engine
- func (eng *Engine) AddDisplayFilterXssJsFilter() *Engine
- func (eng *Engine) AddGenerator(key string, g table.Generator) *Engine
- func (eng *Engine) AddGenerators(list ...table.GeneratorList) *Engine
- func (eng *Engine) AddGlobalDisplayProcessFn(f types.DisplayProcessFn) *Engine
- func (eng *Engine) AddNavButtons(title template2.HTML, icon string, action types.Action) *Engine
- func (eng *Engine) AddPlugins(plugs ...plugins.Plugin) *Engine
- func (eng *Engine) AdminPlugin() *admin.Admin
- func (eng *Engine) Clone(e *Engine) *Engine
- func (eng *Engine) ClonedBySetter(setter Setter) *Engine
- func (eng *Engine) Content(ctx interface{}, panel types.GetPanelFn)
- func (eng *Engine) DB(driver string) db.Connection
- func (eng *Engine) Data(method, url string, handler context.Handler, noAuth ...bool)
- func (eng *Engine) DefaultConnection() db.Connection
- func (eng *Engine) FindPluginByName(name string) (plugins.Plugin, bool)
- func (eng *Engine) HTML(method, url string, fn types.GetPanelInfoFn, noAuth ...bool)
- func (eng *Engine) HTMLFile(method, url, path string, data map[string]interface{}, noAuth ...bool)
- func (eng *Engine) HTMLFiles(method, url string, data map[string]interface{}, files ...string)
- func (eng *Engine) HTMLFilesNoAuth(method, url string, data map[string]interface{}, files ...string)
- func (eng *Engine) InitDatabase() *Engine
- func (eng *Engine) MssqlConnection() db.Connection
- func (eng *Engine) MysqlConnection() db.Connection
- func (eng *Engine) PostgresqlConnection() db.Connection
- func (eng *Engine) ResolveConnection(setter ConnectionSetter, driver string) *Engine
- func (eng *Engine) ResolveMssqlConnection(setter ConnectionSetter) *Engine
- func (eng *Engine) ResolveMysqlConnection(setter ConnectionSetter) *Engine
- func (eng *Engine) ResolvePostgresqlConnection(setter ConnectionSetter) *Engine
- func (eng *Engine) ResolveSqliteConnection(setter ConnectionSetter) *Engine
- func (eng *Engine) SetCaptcha(captcha map[string]string) *Engine
- func (eng *Engine) SetCaptchaDriver(driver string) *Engine
- func (eng *Engine) SqliteConnection() db.Connection
- func (eng *Engine) Use(router interface{}) error
- func (eng *Engine) User(ctx interface{}) (models.UserModel, bool)
- type Setter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Content ¶
func Content(ctx interface{}, panel types.GetPanelFn)
Content call the Content method of defaultAdapter. If defaultAdapter is nil, it will panic. Engine.Adapter(interface)不能為空,利用cookie驗證使用者,取得role、permission、menu,接著檢查權限,執行模板並導入HTML
func Register ¶
func Register(ada adapter.WebFrameWork)
Register set default adapter of engine. 建立引擎預設的配適器
Types ¶
type Engine ¶
type Engine struct { // GetRequest回傳插件中的所有路徑 // InitPlugin初始化插件,類似於初始化資料庫並設置及配置路徑 PluginList []plugins.Plugin //interface Adapter adapter.WebFrameWork //interface //Services在modules\service\service.go Services service.List //Services類別為map[string]Service,Service為interface(Name方法) // contains filtered or unexported fields }
Engine is the core component of goAdmin. It has two attributes. PluginList is an array of plugin. Adapter is the adapter of web framework context and goAdmin context. The relationship of adapter and plugin is that the adapter use the plugin which contains routers and controller methods to inject into the framework entity and make it work. 核心組件,有PluginList及Adapter兩個屬性
func Default ¶
func Default() *Engine
Default return the default engine instance. 回傳預設的Engine(struct)
func (*Engine) AddAdapter ¶
func (eng *Engine) AddAdapter(ada adapter.WebFrameWork) *Engine
AddAdapter add the adapter of engine. 設定Engine.Adapter與defaultAdapter,回傳設定Engine(struct)
func (*Engine) AddAuthService ¶
AddAuthService customize the auth logic with given callback function. 增加身分驗證,回傳Engine
func (*Engine) AddConfig ¶
AddConfig set the global config. 設置global config後初始化所有資料庫連線(設置Engine.Services)並啟動引擎
func (*Engine) AddConfigFromINI ¶
AddConfigFromINI set the global config from ini file.
func (*Engine) AddConfigFromJSON ¶
AddConfigFromJSON set the global config from json file.
func (*Engine) AddConfigFromYAML ¶
AddConfigFromYAML set the global config from yaml file.
func (*Engine) AddDisplayFilterLimit ¶
AddDisplayFilterLimit call types.AddDisplayFilterLimit. 加入func(value string) string至FieldDisplay.DisplayProcessFnChains([]DisplayProcessFn) 透過參數limit判斷func(value string)回傳的值
func (*Engine) AddDisplayFilterSubstr ¶
AddDisplayFilterSubstr call types.AddDisplayFilterSubstr. 加入func(value string) string至參數globalDisplayProcessChains([]DisplayProcessFn) 透過參數start、end判斷func(value string)回傳的值
func (*Engine) AddDisplayFilterToLower ¶
AddDisplayFilterToLower call types.AddDisplayFilterToLower. 加入func(value string) string至globalDisplayProcessChains([]DisplayProcessFn) func(value string)回傳值為strings.ToLower(value)
func (*Engine) AddDisplayFilterToTitle ¶
AddDisplayFilterToTitle call types.AddDisplayFilterToTitle. 加入func(value string) string至globalDisplayProcessChains([]DisplayProcessFn) func(value string)回傳值為strings.Title(value)
func (*Engine) AddDisplayFilterToUpper ¶
AddDisplayFilterToUpper call types.AddDisplayFilterToUpper. 加入func(value string) string至globalDisplayProcessChains([]DisplayProcessFn) func(value string)回傳值為strings.ToUpper(value)
func (*Engine) AddDisplayFilterTrimSpace ¶
AddDisplayFilterTrimSpace call types.AddDisplayFilterTrimSpace. 加入func(value string) string至DisplayProcessFnChains([]DisplayProcessFn) func(value string)回傳值為strings.TrimSpace(value)
func (*Engine) AddDisplayFilterXssFilter ¶
AddDisplayFilterXssFilter call types.AddDisplayFilterXssFilter. 加入func(value string) string至globalDisplayProcessChains([]DisplayProcessFn) func(value string)回傳值為html.EscapeString(value)
func (*Engine) AddDisplayFilterXssJsFilter ¶
AddDisplayFilterXssJsFilter call types.AddDisplayFilterXssJsFilter. 加入func(value string) string至globalDisplayProcessChains([]DisplayProcessFn) func(value string)回傳值為replacer.Replace(value)
func (*Engine) AddGenerator ¶
AddGenerator add table model generator. AddGenerator將參數key及g(function)添加至Admin.tableList(map[string]Generator)
func (*Engine) AddGenerators ¶
func (eng *Engine) AddGenerators(list ...table.GeneratorList) *Engine
AddGenerators add the admin generators. 判斷plug是否存在,如存在則透過參數LIST(多個)判斷GeneratorList已經有該key、value,如果不存在則加入該鍵與值至Admin.tableList 如不存在,設置的Admin(struct)加至Engine.PluginList
func (*Engine) AddGlobalDisplayProcessFn ¶
func (eng *Engine) AddGlobalDisplayProcessFn(f types.DisplayProcessFn) *Engine
AddGlobalDisplayProcessFn call types.AddGlobalDisplayProcessFn. 將參數f(func(string) string)加入globalDisplayProcessChains([]DisplayProcessFn)
func (*Engine) AddNavButtons ¶
AddNavButtons add the nav buttons. Action是interface 新增一個NavButton(struct)並設置至Engine.NavButtons
func (*Engine) AddPlugins ¶
AddPlugins add the plugins and initialize them. 增加plugins以及初始化
func (*Engine) AdminPlugin ¶
AdminPlugin get the admin plugin. if not exist, create one. 判斷plug是否存在,如存在則將plug轉換成Admin(struct)類別並回傳 如不存在,設置的Admin(struct)加至Engine.PluginList並回傳Admin(struct)
func (*Engine) ClonedBySetter ¶
ClonedBySetter copy a new Engine by a setter callback function. 透過Setter(function)複製一個新Engine
func (*Engine) Content ¶
func (eng *Engine) Content(ctx interface{}, panel types.GetPanelFn)
Content call the Content method of engine adapter. If adapter is nil, it will panic. Engine.Adapter(interface)不能為空,// 利用cookie驗證使用者,取得role、permission、menu,接著檢查權限,執行模板並導入HTML
func (*Engine) DB ¶
func (eng *Engine) DB(driver string) db.Connection
DB return the db connection of given driver. 透過參數(driver)找到匹配的Service(interface)後回傳Connection(interface)型態 Service(interface)也具有db.Connection(interface)型態,因為都具有Name方法
func (*Engine) Data ¶
Data inject the route and corresponding handler to the web framework. 將route以及相對應的處理程序加入Web框架 設置context.Context增加handlers、處理url及寫入header,最後取得新的request handle與middleware
func (*Engine) DefaultConnection ¶
func (eng *Engine) DefaultConnection() db.Connection
DefaultConnection return the default db connection. 回傳預設的Connection(interface)
func (*Engine) FindPluginByName ¶
FindPluginByName find the register plugin by given name. 透過參數(name)找到符合的plugin
func (*Engine) HTML ¶
func (eng *Engine) HTML(method, url string, fn types.GetPanelInfoFn, noAuth ...bool)
HTML inject the route and corresponding handler wrapped by the given function to the web framework. type GetPanelInfoFn func(ctx *context.Context) (Panel, error) 透過function將route以及相對應的處理程序加入Web框架 建立一個handler後設置context.Context增加handlers、處理url及寫入header,最後取得新的request handle與middleware
func (*Engine) HTMLFile ¶
HTMLFile inject the route and corresponding handler which returns the panel content of given html file path to the web framework. 將route以及相對應的處理程序加入Web框架(該程序回傳html文件的面板(panel)內容) 建立一個handler後設置context.Context增加handlers、處理url及寫入header,最後取得新的request handle與middleware
func (*Engine) HTMLFiles ¶
HTMLFiles inject the route and corresponding handler which returns the panel content of given html files path to the web framework. 將route以及相對應的處理程序加入Web框架(該程序回傳html文件(多個文件)的面板(panel)內容),需身分驗證 設置context.Context增加handlers、處理url及寫入header,最後取得新的request handle與middleware
func (*Engine) HTMLFilesNoAuth ¶
func (eng *Engine) HTMLFilesNoAuth(method, url string, data map[string]interface{}, files ...string)
HTMLFilesNoAuth inject the route and corresponding handler which returns the panel content of given html files path to the web framework without auth check. 將route以及相對應的處理程序加入Web框架(該程序回傳html文件(多個文件)的面板(panel)內容),無須身分驗證 設置context.Context增加handlers、處理url及寫入header,最後取得新的request handle與middleware
func (*Engine) InitDatabase ¶
InitDatabase initialize all database connection. 初始化所有資料庫連線(將driver加入Engine.Services)並啟動引擎
func (*Engine) MssqlConnection ¶
func (eng *Engine) MssqlConnection() db.Connection
MssqlConnection return the mssql db connection of given driver. 取得匹配mssql的Service後回傳Connection(interface) Service(interface)也具有db.Connection(interface)型態,因為都具有Name方法
func (*Engine) MysqlConnection ¶
func (eng *Engine) MysqlConnection() db.Connection
MysqlConnection return the mysql db connection of given driver. 取得匹配mysql的Service後回傳Connection(interface) Service(interface)也具有db.Connection(interface)型態,因為都具有Name方法
func (*Engine) PostgresqlConnection ¶
func (eng *Engine) PostgresqlConnection() db.Connection
PostgresqlConnection return the postgresql db connection of given driver. 取得匹配postgresql的Service後回傳Connection(interface) Service(interface)也具有db.Connection(interface)型態,因為都具有Name方法
func (*Engine) ResolveConnection ¶
func (eng *Engine) ResolveConnection(setter ConnectionSetter, driver string) *Engine
ResolveConnection resolve the specified driver connection. 解決特別driver連接
func (*Engine) ResolveMssqlConnection ¶
func (eng *Engine) ResolveMssqlConnection(setter ConnectionSetter) *Engine
ResolveMssqlConnection resolve the mssql connection.
func (*Engine) ResolveMysqlConnection ¶
func (eng *Engine) ResolveMysqlConnection(setter ConnectionSetter) *Engine
ResolveMysqlConnection resolve the mysql connection. 解決mysql連接
func (*Engine) ResolvePostgresqlConnection ¶
func (eng *Engine) ResolvePostgresqlConnection(setter ConnectionSetter) *Engine
ResolvePostgresqlConnection resolve the postgres connection.
func (*Engine) ResolveSqliteConnection ¶
func (eng *Engine) ResolveSqliteConnection(setter ConnectionSetter) *Engine
ResolveSqliteConnection resolve the sqlite connection.
func (*Engine) SetCaptcha ¶
SetCaptcha set the captcha config. 將參數captcha(驗證碼)設置至Admin.handler.captchaConfig(struct)
func (*Engine) SetCaptchaDriver ¶
SetCaptchaDriver set the captcha config with driver. SetCaptchaDriver將參數map[string]string{"driver": driver}(驗證碼)設置至Admin.handler.captchaConfig(struct)
func (*Engine) SqliteConnection ¶
func (eng *Engine) SqliteConnection() db.Connection
SqliteConnection return the sqlite db connection of given driver. 取得匹配sqlite的Service後回傳Connection(interface) Service(interface)也具有db.Connection(interface)型態,因為都具有Name方法
func (*Engine) Use ¶
Use enable the adapter. 尋找符合的plugin,接著設置context.Context(struct)與設置url與寫入header,取得新的request與middleware