App configuration
-
AppName
Application name, the default is beego. By
bee new
create is the name of the created project.beego.BConfig.AppName = "beego"
-
RunMode
The running mode of the application, the optional value is
prod
,dev
ortest
. The default isdev
, it is the development mode, and a friendly error page will be prompted if an error occurs in the development mode, as described in the previous error description.beego.BConfig.RunMode = "dev"
-
RouterCaseSensitive
Whether the route ignores case matching, the default is true, case sensitive
beego.BConfig.RouterCaseSensitive = true
-
ServerName
By default, the beego server outputs server as beego when requesting.
beego.BConfig.ServerName = "beego"
-
RecoverPanic
Whether to restore abnormally, the default value is true, that is, when an abnormal situation occurs in the application, it can be recovered through recover without causing the application to exit abnormally.
beego.BConfig.RecoverPanic = true
-
CopyRequestBody
Whether it is allowed to return the original request body data bytes in HTTP requests, the default is false (except for GET or HEAD or upload file requests).
beego.BConfig.CopyRequestBody = false
-
EnableGzip
Whether to enable gzip support, the default is false and gzip is not supported, once gzip is enabled, the content output in the template will be compressed with gzip or zlib, depending on the user's Accept-Encoding.
beego.BConfig.EnableGzip = false
Gzip allows users to customize compression level, compression length threshold and compression for request type:
-
Compression level,
gzipCompressLevel = 9
, the value is 1~9, if not set to 1 (fastest compression) -
Compression length threshold,
gzipMinLength = 256
, when the original content length is greater than this threshold, the compression will be enabled, the default is 20B (ngnix default length) -
Request type,
includedMethods = get;post
, for which request types are compressed, the default is only compressed for GET requests
-
-
MaxMemory
File upload default memory cache size, the default value is
1 << 26
(64M).beego.BConfig.MaxMemory = 1 << 26
-
EnableErrorsShow
Whether to display system error messages, the default is true.
beego.BConfig.EnableErrorsShow = true
-
EnableErrorsRender
Whether to render error information, the default value is true, that is, a friendly error page will be prompted when an error occurs. For API type applications, this option may need to be set to false to prevent unnecessary template rendering information from being returned in the mode
dev
.
web configuration
-
AutoRender
Whether to automatically render the template, the default value is true, for the application of API type, the application needs to set this option to false, and the template does not need to be rendered.
beego.BConfig.WebConfig.AutoRender = true
-
EnableDocs
Whether to enable the built-in function of the document, the default is false
beego.BConfig.WebConfig.EnableDocs = true
-
FlashName
The name of the cookie when Flash data is set, the default is BEEGO_FLASH
beego.BConfig.WebConfig.FlashName = "BEEGO_FLASH"
-
FlashSeperator
Flash data delimiter, the default is BEEGOFLASH
beego.BConfig.WebConfig.FlashSeparator = "BEEGOFLASH"
-
DirectoryIndex
Whether to enable the list display of the static directory, the directory is not displayed by default, and a 403 error is returned.
beego.BConfig.WebConfig.DirectoryIndex = false
-
StaticDir
Static file directory setting, the default is static
Single or multiple directories can be configured:
-
For a single directory,
StaticDir = download
. is equivalent tobeego.SetStaticPath("/download","download")
-
For multiple directories,
StaticDir = download:down download2:down2
. is equivalent tobeego.SetStaticPath("/download","down")
andbeego.SetStaticPath("/download2","down2")
beego.BConfig.WebConfig.StaticDir
-
-
StaticExtensionsToGzip
Which static files with suffixes are allowed to be compressed by gzip, and .css and .js are supported by default
beego.BConfig.WebConfig.StaticExtensionsToGzip = []string{".css", ".js"}
In the equivalent config file
StaticExtensionsToGzip = .css, .js
-
TemplateLeft
Template left label, the default value is
{ {
.beego.BConfig.WebConfig.TemplateLeft="{ {"
-
TemplateRight
Template right label, the default value is
}}
.beego.BConfig.WebConfig.TemplateRight="}}"
-
ViewsPath
Template path, the default value is views.
beego.BConfig.WebConfig.ViewsPath="views"
-
EnableXSRF
Whether to enable XSRF, the default is false, not enabled.
beego.BConfig.WebConfig.EnableXSRF = false
-
XSRFKEY
The key information of XSRF, the default value is beegoxsrf. EnableXSRF=true is valid
beego.BConfig.WebConfig.XSRFKEY = "beegoxsrf"
-
XSRFExpire
XSRF expiration time, the default value is 0, no expiration.
beego.BConfig.WebConfig.XSRFExpire = 0
Monitor configuration
-
Graceful
Whether to enable hot upgrade, the default is false, turn off hot upgrade.
beego.BConfig.Listen.Graceful=false
-
ServerTimeOut
Set HTTP timeout, the default is 0, no timeout.
beego.BConfig.Listen.ServerTimeOut=0
-
ListenTCP4
Listen to the local network address type, the default is TCP6, and it can be set to TCP4 by setting it to true.
beego.BConfig.Listen.ListenTCP4 = true
-
EnableHTTP
Whether to enable HTTP monitoring, the default is true.
beego.BConfig.Listen.EnableHTTP = true
-
HTTPAddr
The application monitor address, which is empty by default, monitors all network card IPs.
beego.BConfig.Listen.HTTPAddr = ""
-
HTTPPort
Application listening port, the default is 8080.
beego.BConfig.Listen.HTTPPort = 8080
-
EnableHTTPS
Whether to enable HTTPS, the default is false and off. When it needs to be enabled, first set EnableHTTPS = true, and set
HTTPSCertFile
andHTTPSKeyFile
beego.BConfig.Listen.EnableHTTPS = false
-
HTTPSAddr
The application monitor address, which is empty by default, monitors all network card IPs.
beego.BConfig.Listen.HTTPSAddr = ""
-
HTTPSPort
Application listening port, the default is 10443
beego.BConfig.Listen.HTTPSPort = 10443
-
HTTPSCertFile
After HTTPS is enabled, the ssl certificate path is empty by default.
beego.BConfig.Listen.HTTPSCertFile = "conf/ssl.crt"
-
HTTPSKeyFile
After enabling HTTPS, the path of the SSL certificate keyfile.
beego.BConfig.Listen.HTTPSKeyFile = "conf/ssl.key"
-
EnableAdmin
Whether to open the in-process monitoring module, the default is false to close.
beego.BConfig.Listen.EnableAdmin = false
-
AdminAddr
The address that the monitoring program listens to, the default value is localhost.
beego.BConfig.Listen.AdminAddr = "localhost"
-
AdminPort
The address that the monitoring program listens to, the default value is 8088.
beego.BConfig.Listen.AdminPort = 8088
-
EnableFcgi
Whether to enable fastcgi, the default is false.
beego.BConfig.Listen.EnableFcgi = false
-
EnableStdIo
Through fastcgi standard I/O, it will take effect after fastcgi is enabled, and the default is false.
beego.BConfig.Listen.EnableStdIo = false
Session configuration
-
SessionOn
Whether session is enabled, the default is false.
beego.BConfig.WebConfig.Session.SessionOn = false
-
SessionProvider
The session engine, the default is memory, see for details
session 模块
.beego.BConfig.WebConfig.Session.SessionProvider = ""
-
SessionName
The cookie name of the existing client, the default value is beegosessionID.
beego.BConfig.WebConfig.Session.SessionName = "beegosessionID"
-
SessionGCMaxLifetime
Session expiration time, the default value is 3600 seconds.
beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 3600
-
SessionProviderConfig
Configuration information, set different configuration information according to different engines, please refer to the engine settings below for detailed configuration, see session module for details
-
SessionCookieLifeTime
Session defaults to the client's cookie time, and the default value is 3600 seconds.
beego.BConfig.WebConfig.Session.SessionCookieLifeTime = 3600
-
SessionAutoSetCookie
Whether to enable SetCookie, the default value is true.
beego.BConfig.WebConfig.Session.SessionAutoSetCookie = true
-
SessionDomain
The session cookie stores the domain name, which is empty by default.
beego.BConfig.WebConfig.Session.SessionDomain = ""
Log configuration
log详细配置,请参见 `logs 模块`。
-
AccessLogs
Whether to output logs to Log, the default is not to output logs in prod mode, and the default is false to not output logs. This parameter does not support profile configuration.
beego.BConfig.Log.AccessLogs = false
-
FileLineNum
Whether to display the file name and output log line number in the log, the default is true. This parameter does not support profile configuration.
beego.BConfig.Log.FileLineNum = true
-
Outputs
For log output configuration, refer to logs module, console file and other configurations. This parameter does not support configuration file configuration.
beego.BConfig.Log.Outputs = map[string]string{"console": ""}
or
beego.BConfig.Log.Outputs["console"] = ""