config

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2019 License: Apache-2.0 Imports: 9 Imported by: 405

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

This section is empty.

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

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

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

	// The global url prefix.
	UrlPrefix string `json:"prefix"`

	// The theme name of template.
	Theme string `json:"theme"`

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

	// The title of web page.
	Title string `json:"title"`

	Logo template.HTML `json:"logo"`

	MiniLogo template.HTML `json:"mini_logo"`

	// The url redirect to after login.
	IndexUrl string `json:"index"`

	// Debug mode
	Debug bool `json:"debug"`

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

	// Info log path.
	InfoLogPath string `json:"info_log"`

	// Error log path.
	ErrorLogPath string `json:"error_log"`

	// Access log path.
	AccessLogPath string `json:"access_log"`

	// Sql operator record log switch.
	SqlLog bool `json:"sql_log"`

	AccessLogOff bool `json:"access_log_off"`
	InfoLogOff   bool `json:"info_log_off"`
	ErrorLogOff  bool `json:"error_log_off"`

	// Color scheme.
	ColorScheme string `json:"color_scheme"`

	// Session valid time duration, units are seconds.
	SessionLifeTime int `json:"session_life_time"`

	// Assets visit link.
	AssetUrl string `json:"asset_url"`

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

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

	// Custom html after body.
	CustomFootHtml template.HTML `json:"custom_foot_html"`

	// Login page title
	LoginTitle string `json:"login_title"`

	LoginLogo template.HTML `json:"login_logo"`
	// 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 ReadFromJson added in v1.0.0

func ReadFromJson(path string) Config

ReadFromJson read the Config from a JSON file.

func Set

func Set(cfg Config) Config

Set sets the config.

func (Config) GetIndexURL added in v1.0.8

func (c Config) GetIndexURL() string

GetIndexURL get the index url with prefix.

func (Config) Index added in v1.0.0

func (c Config) Index() string

Index return the index url without prefix.

func (Config) IsLocalEnvironment added in v1.0.0

func (c Config) IsLocalEnvironment() bool

IsLocalEnvironment check the environment if it is local.

func (Config) IsProductionEnvironment added in v1.0.0

func (c Config) IsProductionEnvironment() bool

IsProductionEnvironment check the environment if it is production.

func (Config) IsTestEnvironment added in v1.0.0

func (c Config) IsTestEnvironment() bool

IsTestEnvironment check the environment if it is test.

func (Config) Prefix added in v1.0.0

func (c Config) Prefix() string

Prefix return the prefix.

func (Config) PrefixFixSlash added in v1.0.0

func (c Config) PrefixFixSlash() string

PrefixFixSlash return the prefix fix the slash error.

func (Config) URLRemovePrefix added in v1.0.8

func (c Config) URLRemovePrefix(url string) string

URLRemovePrefix remove prefix from the given url.

func (Config) Url added in v1.0.0

func (c Config) Url(suffix string) string

Url get url with the given suffix.

type Database

type Database struct {
	Host       string `json:"host"`
	Port       string `json:"port"`
	User       string `json:"user"`
	Pwd        string `json:"pwd"`
	Name       string `json:"name"`
	MaxIdleCon int    `json:"max_idle_con"`
	MaxOpenCon int    `json:"max_open_con"`
	Driver     string `json:"driver"`
	File       string `json:"file"`
	Dsn        string `json:"dsn"`
}

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.

type DatabaseList added in v1.0.0

type DatabaseList map[string]Database

DatabaseList is a map of Database.

func (DatabaseList) Add added in v1.0.0

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

Add add a Database to the DatabaseList.

func (DatabaseList) GetDefault added in v1.0.0

func (d DatabaseList) GetDefault() Database

GetDefault get the default Database.

func (DatabaseList) GroupByDriver added in v1.0.0

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

GroupByDriver group the Databases with the drivers.

type FileUploadEngine added in v1.0.0

type FileUploadEngine struct {
	Name   string
	Config map[string]interface{}
}

FileUploadEngine is a file upload engine.

type Store

type Store struct {
	Path   string
	Prefix string
}

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

Jump to

Keyboard shortcuts

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