config

package
v1.2.24 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
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"
)

Variables

This section is empty.

Functions

func AssertPrefix

func AssertPrefix() string

AssertPrefix return the prefix of assert.

func GetAccessLogOff

func GetAccessLogOff() bool

func GetAccessLogPath

func GetAccessLogPath() string

func GetAllowDelOperationLog

func GetAllowDelOperationLog() bool

func GetAppID

func GetAppID() string

func GetAssetRootPath

func GetAssetRootPath() string

func GetAssetUrl

func GetAssetUrl() string

func GetAuthUserTable

func GetAuthUserTable() string

func GetColorScheme

func GetColorScheme() string

func GetCustom403HTML

func GetCustom403HTML() template.HTML

func GetCustom404HTML

func GetCustom404HTML() template.HTML

func GetCustom500HTML

func GetCustom500HTML() template.HTML

func GetCustomFootHtml

func GetCustomFootHtml() template.HTML

func GetCustomHeadHtml

func GetCustomHeadHtml() template.HTML

func GetDebug

func GetDebug() bool

func GetDomain

func GetDomain() string

func GetEnv

func GetEnv() string

func GetErrorLogOff

func GetErrorLogOff() bool

func GetErrorLogPath

func GetErrorLogPath() string

func GetExcludeThemeComponents

func GetExcludeThemeComponents() []string

func GetExtra

func GetExtra() map[string]interface{}

func GetFooterInfo

func GetFooterInfo() template.HTML

func GetHideVisitorUserCenterEntrance

func GetHideVisitorUserCenterEntrance() bool

func GetIndexURL

func GetIndexURL() string

GetIndexURL get the index url with prefix.

func GetIndexUrl

func GetIndexUrl() string

func GetInfoLogOff

func GetInfoLogOff() bool

func GetInfoLogPath

func GetInfoLogPath() string

func GetLanguage

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

func GetLoginTitle

func GetLoginTitle() string

func GetLoginUrl

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

func GetNoLimitLoginIP

func GetNoLimitLoginIP() bool

func GetOpenAdminApi

func GetOpenAdminApi() bool

func GetOperationLogOff

func GetOperationLogOff() bool

func GetSessionLifeTime

func GetSessionLifeTime() int

func GetSiteOff

func GetSiteOff() bool

func GetSqlLog

func GetSqlLog() bool

func GetTheme

func GetTheme() string

func GetTitle

func GetTitle() string

func GetUrlPrefix

func GetUrlPrefix() string

func IsNotProductionEnvironment

func IsNotProductionEnvironment() bool

IsNotProductionEnvironment check the environment if it is not production.

func IsProductionEnvironment

func IsProductionEnvironment() bool

IsProductionEnvironment check the environment if it is production.

func Prefix

func Prefix() string

Prefix return the prefix.

func PrefixFixSlash

func PrefixFixSlash() string

PrefixFixSlash return the prefix fix the slash error.

func URLRemovePrefix

func URLRemovePrefix(url string) string

URLRemovePrefix remove prefix from the given url.

func Url

func Url(suffix string) string

Types

type Config

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 application unique ID. Once generated, don't modify.
	AppID string `json:"app_id,omitempty" yaml:"app_id,omitempty" ini:"app_id,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 template.HTML `json:"logo,omitempty" yaml:"logo,omitempty" ini:"logo,omitempty"`

	MiniLogo 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"`

	LoginLogo 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 `` /* 133-byte string literal not displayed */

	// Prohibit config modification
	ProhibitConfigModification bool `` /* 136-byte string literal not displayed */

	// 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:"-" ini:"-"`

	// 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 `` /* 151-byte string literal not displayed */

	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"`

	GoModFilePath string `json:"go_mod_file_path,omitempty" yaml:"go_mod_file_path,omitempty" ini:"go_mod_file_path,omitempty"`

	AllowDelOperationLog bool `json:"allow_del_operation_log,omitempty" yaml:"allow_del_operation_log,omitempty" ini:"allow_del_operation_log,omitempty"`

	OperationLogOff bool `json:"operation_log_off,omitempty" yaml:"operation_log_off,omitempty" ini:"operation_log_off,omitempty"`

	AssetRootPath string `json:"asset_root_path,omitempty" yaml:"asset_root_path,omitempty" ini:"asset_root_path,omitempty"`

	URLFormat URLFormat `json:"url_format,omitempty" yaml:"url_format,omitempty" ini:"url_format,omitempty"`
	// contains filtered or unexported fields
}

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

func Get

func Get() *Config

Get gets the config.

func GetService

func GetService(s interface{}) *Config

func Initialize

func Initialize(cfg *Config) *Config

Initialize initialize the config.

func ReadFromINI

func ReadFromINI(path string) Config

ReadFromINI read the Config from a INI file.

func ReadFromJson

func ReadFromJson(path string) Config

ReadFromJson read the Config from a JSON file.

func ReadFromYaml

func ReadFromYaml(path string) Config

ReadFromYaml read the Config from a YAML file.

func SetDefault

func SetDefault(cfg *Config) *Config

func (*Config) AddUpdateProcessFn

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

func (*Config) AssertPrefix

func (c *Config) AssertPrefix() string

AssertPrefix return the prefix of assert.

func (*Config) Copy

func (c *Config) Copy() *Config

func (*Config) EraseSens

func (c *Config) EraseSens() *Config

eraseSens erase sensitive info.

func (*Config) GetIndexURL

func (c *Config) GetIndexURL() string

GetIndexURL get the index url with prefix.

func (*Config) Index

func (c *Config) Index() string

Index return the index url without prefix.

func (*Config) IsAllowConfigModification

func (c *Config) IsAllowConfigModification() bool

func (*Config) IsLocalEnvironment

func (c *Config) IsLocalEnvironment() bool

IsLocalEnvironment check the environment if it is local.

func (*Config) IsNotProductionEnvironment

func (c *Config) IsNotProductionEnvironment() bool

IsNotProductionEnvironment check the environment if it is not production.

func (*Config) IsProductionEnvironment

func (c *Config) IsProductionEnvironment() bool

IsProductionEnvironment check the environment if it is production.

func (*Config) IsTestEnvironment

func (c *Config) IsTestEnvironment() bool

IsTestEnvironment check the environment if it is test.

func (*Config) Prefix

func (c *Config) Prefix() string

Prefix return the prefix.

func (*Config) PrefixFixSlash

func (c *Config) PrefixFixSlash() string

PrefixFixSlash return the prefix fix the slash error.

func (*Config) ToMap

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

func (*Config) URLRemovePrefix

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

URLRemovePrefix remove prefix from the given url.

func (*Config) Update

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

func (*Config) Url

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

Url get url with the given suffix.

type Database

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"`
	DriverMode string            `json:"driver_mode,omitempty" yaml:"driver_mode,omitempty" ini:"driver_mode,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

func (d Database) GetDSN() string

func (Database) ParamStr

func (d Database) ParamStr() string

type DatabaseList

type DatabaseList map[string]Database

DatabaseList is a map of Database.

func GetDatabaseListFromJSON

func GetDatabaseListFromJSON(m string) DatabaseList

func GetDatabases

func GetDatabases() DatabaseList

func (DatabaseList) Add

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

Add add a Database to the DatabaseList.

func (DatabaseList) Connections

func (d DatabaseList) Connections() []string

func (DatabaseList) Copy

func (d DatabaseList) Copy() DatabaseList

func (DatabaseList) GetDefault

func (d DatabaseList) GetDefault() Database

GetDefault get the default Database.

func (DatabaseList) GroupByDriver

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

GroupByDriver group the Databases with the drivers.

func (DatabaseList) JSON

func (d DatabaseList) JSON() string

type EncoderCfg

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

type ExtraInfo map[string]interface{}

type FileUploadEngine

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

func GetFileUploadEngine() FileUploadEngine

func GetFileUploadEngineFromJSON

func GetFileUploadEngineFromJSON(m string) FileUploadEngine

func (FileUploadEngine) JSON

func (f FileUploadEngine) JSON() string

type Logger

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

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

func GetAnimation() PageAnimation

func (PageAnimation) JSON

func (p PageAnimation) JSON() string

type RotateCfg

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

type Service struct {
	C *Config
}

func SrvWithConfig

func SrvWithConfig(c *Config) *Service

func (*Service) Name

func (s *Service) Name() string

type Store

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

func GetStore() Store

func GetStoreFromJSON

func GetStoreFromJSON(m string) Store

func (Store) JSON

func (s Store) JSON() string

func (Store) URL

func (s Store) URL(suffix string) string

type URLFormat

type URLFormat struct {
	Info       string `json:"info,omitempty" yaml:"info,omitempty" ini:"info,omitempty"`
	Detail     string `json:"detail,omitempty" yaml:"detail,omitempty" ini:"detail,omitempty"`
	Create     string `json:"create,omitempty" yaml:"create,omitempty" ini:"create,omitempty"`
	Delete     string `json:"delete,omitempty" yaml:"delete,omitempty" ini:"delete,omitempty"`
	Export     string `json:"export,omitempty" yaml:"export,omitempty" ini:"export,omitempty"`
	Edit       string `json:"edit,omitempty" yaml:"edit,omitempty" ini:"edit,omitempty"`
	ShowEdit   string `json:"show_edit,omitempty" yaml:"show_edit,omitempty" ini:"show_edit,omitempty"`
	ShowCreate string `json:"show_create,omitempty" yaml:"show_create,omitempty" ini:"show_create,omitempty"`
	Update     string `json:"update,omitempty" yaml:"update,omitempty" ini:"update,omitempty"`
}

func GetURLFormats

func GetURLFormats() URLFormat

func (URLFormat) SetDefault

func (f URLFormat) SetDefault() URLFormat

type UpdateConfigProcessFn

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

Jump to

Keyboard shortcuts

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