go-admin: github.com/GoAdminGroup/go-admin/modules/config Index | Files

package config

import "github.com/GoAdminGroup/go-admin/modules/config"

Index

Package Files

config.go

Constants

const (
    // EnvTest is a const value of test environment.
    EnvTest = "test"
    // EnvLocal is a const value of local environment.
    EnvLocal = "local"
    // EnvProd is a const value of production environment.
    EnvProd = "prod"

    // DriverMysql is a const value of mysql driver.
    DriverMysql = "mysql"
    // DriverSqlite is a const value of sqlite driver.
    DriverSqlite = "sqlite"
    // DriverPostgresql is a const value of postgresql driver.
    DriverPostgresql = "postgresql"
    // DriverMssql is a const value of mssql driver.
    DriverMssql = "mssql"
)

func AssertPrefix Uses

func AssertPrefix() string

AssertPrefix return the prefix of assert.

func GetAccessLogOff Uses

func GetAccessLogOff() bool

func GetAccessLogPath Uses

func GetAccessLogPath() string

func GetAssetUrl Uses

func GetAssetUrl() string

func GetAuthUserTable Uses

func GetAuthUserTable() string

func GetColorScheme Uses

func GetColorScheme() string

func GetCustom403HTML Uses

func GetCustom403HTML() template.HTML

func GetCustom404HTML Uses

func GetCustom404HTML() template.HTML

func GetCustom500HTML Uses

func GetCustom500HTML() template.HTML

func GetCustomFootHtml Uses

func GetCustomFootHtml() template.HTML

func GetCustomHeadHtml Uses

func GetCustomHeadHtml() template.HTML

func GetDebug Uses

func GetDebug() bool

func GetDomain Uses

func GetDomain() string

func GetEnv Uses

func GetEnv() string

func GetErrorLogOff Uses

func GetErrorLogOff() bool

func GetErrorLogPath Uses

func GetErrorLogPath() string

func GetExcludeThemeComponents Uses

func GetExcludeThemeComponents() []string

func GetExtra Uses

func GetExtra() map[string]interface{}

func GetFooterInfo Uses

func GetFooterInfo() template.HTML

func GetHideVisitorUserCenterEntrance Uses

func GetHideVisitorUserCenterEntrance() bool

func GetIndexURL Uses

func GetIndexURL() string

GetIndexURL get the index url with prefix.

func GetIndexUrl Uses

func GetIndexUrl() string

func GetInfoLogOff Uses

func GetInfoLogOff() bool

func GetInfoLogPath Uses

func GetInfoLogPath() string

func GetLanguage Uses

func GetLanguage() string
func GetLoginLogo() template.HTML

func GetLoginTitle Uses

func GetLoginTitle() string

func GetLoginUrl Uses

func GetLoginUrl() string
func GetLogo() template.HTML
func GetMiniLogo() template.HTML

func GetNoLimitLoginIP Uses

func GetNoLimitLoginIP() bool

func GetOpenAdminApi Uses

func GetOpenAdminApi() bool

func GetSessionLifeTime Uses

func GetSessionLifeTime() int

func GetSiteOff Uses

func GetSiteOff() bool

func GetSqlLog Uses

func GetSqlLog() bool

func GetTheme Uses

func GetTheme() string

func GetTitle Uses

func GetTitle() string

func GetUrlPrefix Uses

func GetUrlPrefix() string

func IsProductionEnvironment Uses

func IsProductionEnvironment() bool

IsProductionEnvironment check the environment if it is production.

func Prefix Uses

func Prefix() string

Prefix return the prefix.

func PrefixFixSlash Uses

func PrefixFixSlash() string

PrefixFixSlash return the prefix fix the slash error.

func URLRemovePrefix Uses

func URLRemovePrefix(url string) string

URLRemovePrefix remove prefix from the given url.

func Url Uses

func Url(suffix string) string

type Config Uses

type Config struct {
    // An map supports multi database connection. The first
    // element of Databases is the default connection. See the
    // file connection.go.
    Databases DatabaseList `json:"database,omitempty" yaml:"database,omitempty" ini:"database,omitempty"`

    // The cookie domain used in the auth modules. see
    // the session.go.
    Domain string `json:"domain,omitempty" yaml:"domain,omitempty" ini:"domain,omitempty"`

    // Used to set as the localize language which show in the
    // interface.
    Language string `json:"language,omitempty" yaml:"language,omitempty" ini:"language,omitempty"`

    // The global url prefix.
    UrlPrefix string `json:"prefix,omitempty" yaml:"prefix,omitempty" ini:"prefix,omitempty"`

    // The theme name of template.
    Theme string `json:"theme,omitempty" yaml:"theme,omitempty" ini:"theme,omitempty"`

    // The path where files will be stored into.
    Store Store `json:"store,omitempty" yaml:"store,omitempty" ini:"store,omitempty"`

    // The title of web page.
    Title string `json:"title,omitempty" yaml:"title,omitempty" ini:"title,omitempty"`

    // Logo is the top text in the sidebar.
     template.HTML `json:"logo,omitempty" yaml:"logo,omitempty" ini:"logo,omitempty"`

    // Mini-logo is the top text in the sidebar when folding.
     template.HTML `json:"mini_logo,omitempty" yaml:"mini_logo,omitempty" ini:"mini_logo,omitempty"`

    // The url redirect to after login.
    IndexUrl string `json:"index,omitempty" yaml:"index,omitempty" ini:"index,omitempty"`

    // Login page URL
    LoginUrl string `json:"login_url,omitempty" yaml:"login_url,omitempty" ini:"login_url,omitempty"`

    // Debug mode
    Debug bool `json:"debug,omitempty" yaml:"debug,omitempty" ini:"debug,omitempty"`

    // Env is the environment,which maybe local,test,prod.
    Env string `json:"env,omitempty" yaml:"env,omitempty" ini:"env,omitempty"`

    // Info log path.
    InfoLogPath string `json:"info_log,omitempty" yaml:"info_log,omitempty" ini:"info_log,omitempty"`

    // Error log path.
    ErrorLogPath string `json:"error_log,omitempty" yaml:"error_log,omitempty" ini:"error_log,omitempty"`

    // Access log path.
    AccessLogPath string `json:"access_log,omitempty" yaml:"access_log,omitempty" ini:"access_log,omitempty"`

    // Access assets log off
    AccessAssetsLogOff bool `json:"access_assets_log_off,omitempty" yaml:"access_assets_log_off,omitempty" ini:"access_assets_log_off,omitempty"`

    // Sql operator record log switch.
    SqlLog bool `json:"sql_log,omitempty" yaml:"sql_log,omitempty" ini:"sql_log,omitempty"`

    AccessLogOff bool `json:"access_log_off,omitempty" yaml:"access_log_off,omitempty" ini:"access_log_off,omitempty"`
    InfoLogOff   bool `json:"info_log_off,omitempty" yaml:"info_log_off,omitempty" ini:"info_log_off,omitempty"`
    ErrorLogOff  bool `json:"error_log_off,omitempty" yaml:"error_log_off,omitempty" ini:"error_log_off,omitempty"`

    Logger Logger `json:"logger,omitempty" yaml:"logger,omitempty" ini:"logger,omitempty"`

    // Color scheme.
    ColorScheme string `json:"color_scheme,omitempty" yaml:"color_scheme,omitempty" ini:"color_scheme,omitempty"`

    // Session valid time duration,units are seconds. Default 7200.
    SessionLifeTime int `json:"session_life_time,omitempty" yaml:"session_life_time,omitempty" ini:"session_life_time,omitempty"`

    // Assets visit link.
    AssetUrl string `json:"asset_url,omitempty" yaml:"asset_url,omitempty" ini:"asset_url,omitempty"`

    // File upload engine,default "local"
    FileUploadEngine FileUploadEngine `json:"file_upload_engine,omitempty" yaml:"file_upload_engine,omitempty" ini:"file_upload_engine,omitempty"`

    // Custom html in the tag head.
    CustomHeadHtml template.HTML `json:"custom_head_html,omitempty" yaml:"custom_head_html,omitempty" ini:"custom_head_html,omitempty"`

    // Custom html after body.
    CustomFootHtml template.HTML `json:"custom_foot_html,omitempty" yaml:"custom_foot_html,omitempty" ini:"custom_foot_html,omitempty"`

    // Footer Info html
    FooterInfo template.HTML `json:"footer_info,omitempty" yaml:"footer_info,omitempty" ini:"footer_info,omitempty"`

    // Login page title
    LoginTitle string `json:"login_title,omitempty" yaml:"login_title,omitempty" ini:"login_title,omitempty"`

    // Login page logo
     template.HTML `json:"login_logo,omitempty" yaml:"login_logo,omitempty" ini:"login_logo,omitempty"`

    // Auth user table
    AuthUserTable string `json:"auth_user_table,omitempty" yaml:"auth_user_table,omitempty" ini:"auth_user_table,omitempty"`

    // Extra config info
    Extra ExtraInfo `json:"extra,omitempty" yaml:"extra,omitempty" ini:"extra,omitempty"`

    // Page animation
    Animation PageAnimation `json:"animation,omitempty" yaml:"animation,omitempty" ini:"animation,omitempty"`

    // Limit login with different IPs
    NoLimitLoginIP bool `json:"no_limit_login_ip,omitempty" yaml:"no_limit_login_ip,omitempty" ini:"no_limit_login_ip,omitempty"`

    // When site off is true, website will be closed
    SiteOff bool `json:"site_off,omitempty" yaml:"site_off,omitempty" ini:"site_off,omitempty"`

    // Hide config center entrance flag
    HideConfigCenterEntrance bool `json:"hide_config_center_entrance,omitempty" yaml:"hide_config_center_entrance,omitempty" ini:"hide_config_center_entrance,omitempty"`

    // Hide app info entrance flag
    HideAppInfoEntrance bool `json:"hide_app_info_entrance,omitempty" yaml:"hide_app_info_entrance,omitempty" ini:"hide_app_info_entrance,omitempty"`

    // Hide tool entrance flag
    HideToolEntrance bool `json:"hide_tool_entrance,omitempty" yaml:"hide_tool_entrance,omitempty" ini:"hide_tool_entrance,omitempty"`

    HidePluginEntrance bool `json:"hide_plugin_entrance,omitempty" yaml:"hide_plugin_entrance,omitempty" ini:"hide_plugin_entrance,omitempty"`

    Custom404HTML template.HTML `json:"custom_404_html,omitempty" yaml:"custom_404_html,omitempty" ini:"custom_404_html,omitempty"`

    Custom403HTML template.HTML `json:"custom_403_html,omitempty" yaml:"custom_403_html,omitempty" ini:"custom_403_html,omitempty"`

    Custom500HTML template.HTML `json:"custom_500_html,omitempty" yaml:"custom_500_html,omitempty" ini:"custom_500_html,omitempty"`

    // Update Process Function
    UpdateProcessFn UpdateConfigProcessFn `json:"-" yaml:"-" ,omitemptyini:"-,omitempty"`

    // Is open admin plugin json api
    OpenAdminApi bool `json:"open_admin_api,omitempty" yaml:"open_admin_api,omitempty" ini:"open_admin_api,omitempty"`

    HideVisitorUserCenterEntrance bool `json:"hide_visitor_user_center_entrance,omitempty" yaml:"hide_visitor_user_center_entrance,omitempty" ini:"hide_visitor_user_center_entrance,omitempty"`

    ExcludeThemeComponents []string `json:"exclude_theme_components,omitempty" yaml:"exclude_theme_components,omitempty" ini:"exclude_theme_components,omitempty"`

    BootstrapFilePath string `json:"bootstrap_file_path,omitempty" yaml:"bootstrap_file_path,omitempty" ini:"bootstrap_file_path,omitempty"`
    // contains filtered or unexported fields
}

Config type is the global config of goAdmin. It will be initialized in the engine.

func Get Uses

func Get() *Config

Get gets the config.

func GetService Uses

func GetService(s interface{}) *Config

func ReadFromINI Uses

func ReadFromINI(path string) Config

ReadFromINI read the Config from a INI file.

func ReadFromJson Uses

func ReadFromJson(path string) Config

ReadFromJson read the Config from a JSON file.

func ReadFromYaml Uses

func ReadFromYaml(path string) Config

ReadFromYaml read the Config from a YAML file.

func Set Uses

func Set(cfg Config) *Config

Set sets the config.

func SetDefault Uses

func SetDefault(cfg Config) Config

func (*Config) AddUpdateProcessFn Uses

func (c *Config) AddUpdateProcessFn(fn UpdateConfigProcessFn) *Config

func (*Config) AssertPrefix Uses

func (c *Config) AssertPrefix() string

AssertPrefix return the prefix of assert.

func (*Config) Copy Uses

func (c *Config) Copy() *Config

func (*Config) EraseSens Uses

func (c *Config) EraseSens() *Config

eraseSens erase sensitive info.

func (*Config) GetIndexURL Uses

func (c *Config) GetIndexURL() string

GetIndexURL get the index url with prefix.

func (*Config) Index Uses

func (c *Config) Index() string

Index return the index url without prefix.

func (*Config) IsLocalEnvironment Uses

func (c *Config) IsLocalEnvironment() bool

IsLocalEnvironment check the environment if it is local.

func (*Config) IsProductionEnvironment Uses

func (c *Config) IsProductionEnvironment() bool

IsProductionEnvironment check the environment if it is production.

func (*Config) IsTestEnvironment Uses

func (c *Config) IsTestEnvironment() bool

IsTestEnvironment check the environment if it is test.

func (*Config) Prefix Uses

func (c *Config) Prefix() string

Prefix return the prefix.

func (*Config) PrefixFixSlash Uses

func (c *Config) PrefixFixSlash() string

PrefixFixSlash return the prefix fix the slash error.

func (*Config) ToMap Uses

func (c *Config) ToMap() map[string]string

func (*Config) URLRemovePrefix Uses

func (c *Config) URLRemovePrefix(url string) string

URLRemovePrefix remove prefix from the given url.

func (*Config) Update Uses

func (c *Config) Update(m map[string]string) error

func (*Config) Url Uses

func (c *Config) Url(suffix string) string

Url get url with the given suffix.

type Database Uses

type Database struct {
    Host       string            `json:"host,omitempty" yaml:"host,omitempty" ini:"host,omitempty"`
    Port       string            `json:"port,omitempty" yaml:"port,omitempty" ini:"port,omitempty"`
    User       string            `json:"user,omitempty" yaml:"user,omitempty" ini:"user,omitempty"`
    Pwd        string            `json:"pwd,omitempty" yaml:"pwd,omitempty" ini:"pwd,omitempty"`
    Name       string            `json:"name,omitempty" yaml:"name,omitempty" ini:"name,omitempty"`
    MaxIdleCon int               `json:"max_idle_con,omitempty" yaml:"max_idle_con,omitempty" ini:"max_idle_con,omitempty"`
    MaxOpenCon int               `json:"max_open_con,omitempty" yaml:"max_open_con,omitempty" ini:"max_open_con,omitempty"`
    Driver     string            `json:"driver,omitempty" yaml:"driver,omitempty" ini:"driver,omitempty"`
    File       string            `json:"file,omitempty" yaml:"file,omitempty" ini:"file,omitempty"`
    Dsn        string            `json:"dsn,omitempty" yaml:"dsn,omitempty" ini:"dsn,omitempty"`
    Params     map[string]string `json:"params,omitempty" yaml:"params,omitempty" ini:"params,omitempty"`
}

Database is a type of database connection config.

Because a little difference of different database driver. The Config has multiple options but may not be used. Such as the sqlite driver only use the File option which can be ignored when the driver is mysql.

If the Dsn is configured, when driver is mysql/postgresql/ mssql, the other configurations will be ignored, except for MaxIdleCon and MaxOpenCon.

func (Database) GetDSN Uses

func (d Database) GetDSN() string

func (Database) ParamStr Uses

func (d Database) ParamStr() string

type DatabaseList Uses

type DatabaseList map[string]Database

DatabaseList is a map of Database.

func GetDatabaseListFromJSON Uses

func GetDatabaseListFromJSON(m string) DatabaseList

func GetDatabases Uses

func GetDatabases() DatabaseList

func (DatabaseList) Add Uses

func (d DatabaseList) Add(key string, db Database)

Add add a Database to the DatabaseList.

func (DatabaseList) Connections Uses

func (d DatabaseList) Connections() []string

func (DatabaseList) Copy Uses

func (d DatabaseList) Copy() DatabaseList

func (DatabaseList) GetDefault Uses

func (d DatabaseList) GetDefault() Database

GetDefault get the default Database.

func (DatabaseList) GroupByDriver Uses

func (d DatabaseList) GroupByDriver() map[string]DatabaseList

GroupByDriver group the Databases with the drivers.

func (DatabaseList) JSON Uses

func (d DatabaseList) JSON() string

type EncoderCfg Uses

type EncoderCfg struct {
    TimeKey       string `json:"time_key,omitempty" yaml:"time_key,omitempty" ini:"time_key,omitempty"`
    LevelKey      string `json:"level_key,omitempty" yaml:"level_key,omitempty" ini:"level_key,omitempty"`
    NameKey       string `json:"name_key,omitempty" yaml:"name_key,omitempty" ini:"name_key,omitempty"`
    CallerKey     string `json:"caller_key,omitempty" yaml:"caller_key,omitempty" ini:"caller_key,omitempty"`
    MessageKey    string `json:"message_key,omitempty" yaml:"message_key,omitempty" ini:"message_key,omitempty"`
    StacktraceKey string `json:"stacktrace_key,omitempty" yaml:"stacktrace_key,omitempty" ini:"stacktrace_key,omitempty"`
    Level         string `json:"level,omitempty" yaml:"level,omitempty" ini:"level,omitempty"`
    Time          string `json:"time,omitempty" yaml:"time,omitempty" ini:"time,omitempty"`
    Duration      string `json:"duration,omitempty" yaml:"duration,omitempty" ini:"duration,omitempty"`
    Caller        string `json:"caller,omitempty" yaml:"caller,omitempty" ini:"caller,omitempty"`
    Encoding      string `json:"encoding,omitempty" yaml:"encoding,omitempty" ini:"encoding,omitempty"`
}

type ExtraInfo Uses

type ExtraInfo map[string]interface{}

type FileUploadEngine Uses

type FileUploadEngine struct {
    Name   string                 `json:"name,omitempty" yaml:"name,omitempty" ini:"name,omitempty"`
    Config map[string]interface{} `json:"config,omitempty" yaml:"config,omitempty" ini:"config,omitempty"`
}

FileUploadEngine is a file upload engine.

func GetFileUploadEngine Uses

func GetFileUploadEngine() FileUploadEngine

func GetFileUploadEngineFromJSON Uses

func GetFileUploadEngineFromJSON(m string) FileUploadEngine

func (FileUploadEngine) JSON Uses

func (f FileUploadEngine) JSON() string

type Logger Uses

type Logger struct {
    Encoder EncoderCfg `json:"encoder,omitempty" yaml:"encoder,omitempty" ini:"encoder,omitempty"`
    Rotate  RotateCfg  `json:"rotate,omitempty" yaml:"rotate,omitempty" ini:"rotate,omitempty"`
    Level   int8       `json:"level,omitempty" yaml:"level,omitempty" ini:"level,omitempty"`
}

type PageAnimation Uses

type PageAnimation struct {
    Type     string  `json:"type,omitempty" yaml:"type,omitempty" ini:"type,omitempty"`
    Duration float32 `json:"duration,omitempty" yaml:"duration,omitempty" ini:"duration,omitempty"`
    Delay    float32 `json:"delay,omitempty" yaml:"delay,omitempty" ini:"delay,omitempty"`
}

see more: https://daneden.github.io/animate.css/

func GetAnimation Uses

func GetAnimation() PageAnimation

func (PageAnimation) JSON Uses

func (p PageAnimation) JSON() string

type RotateCfg Uses

type RotateCfg struct {
    MaxSize    int  `json:"max_size,omitempty" yaml:"max_size,omitempty" ini:"max_size,omitempty"`
    MaxBackups int  `json:"max_backups,omitempty" yaml:"max_backups,omitempty" ini:"max_backups,omitempty"`
    MaxAge     int  `json:"max_age,omitempty" yaml:"max_age,omitempty" ini:"max_age,omitempty"`
    Compress   bool `json:"compress,omitempty" yaml:"compress,omitempty" ini:"compress,omitempty"`
}

type Service Uses

type Service struct {
    C *Config
}

func SrvWithConfig Uses

func SrvWithConfig(c *Config) *Service

func (*Service) Name Uses

func (s *Service) Name() string

type Store Uses

type Store struct {
    Path   string `json:"path,omitempty" yaml:"path,omitempty" ini:"path,omitempty"`
    Prefix string `json:"prefix,omitempty" yaml:"prefix,omitempty" ini:"prefix,omitempty"`
}

Store is the file store config. Path is the local store path. and prefix is the url prefix used to visit it.

func GetStore Uses

func GetStore() Store

func GetStoreFromJSON Uses

func GetStoreFromJSON(m string) Store

func (Store) JSON Uses

func (s Store) JSON() string

func (Store) URL Uses

func (s Store) URL(suffix string) string

type UpdateConfigProcessFn Uses

type UpdateConfigProcessFn func(values form.Values) (form.Values, error)

Package config imports 13 packages (graph) and is imported by 88 packages. Updated 2020-07-03. Refresh now. Tools for package owners.