配置文件內的key不區分大小寫css
#App配置 for Api AppName = ApiService RunMode = dev RouterCaseSensitive = true ServerName = ApiService RecoverPanic = true CopyRequestBody = true EnableGzip = false MaxMemory = 1 << 26 EnableErrorsShow = true EnableErrorsRender = false
AppName 應用名稱,經過bee new建立的項目名AppName = beego
beego.BConfig.AppName = "beego"
web
RunMode 可選prod、dev、test。默認dev爲開發模式有日誌打印,prod會關閉日誌的打印,test測試模式還沒用過RunMode = dev
beego.BConfig.RunMode = "dev"
緩存
RouterCaseSensitive 路由忽略大小寫匹配,默認爲true,意思是不須要刻意配置RouterCaseSensitive = true
beego.BConfig.RouterCaseSensitive = true
bash
ServerName beego 服務器默認在請求的時候輸出 server 爲 beegoServerName = beego
beego.BConfig.ServerName = "beego"
服務器
RecoverPanic 是否異常恢復,默認值爲 true,即當應用出現異常的狀況,經過 recover 恢復回來,而不會致使應用異常退出。意思是不須要刻意配置RecoverPanic = true
beego.BConfig.RecoverPanic = true
cookie
CopyRequestBody 是否容許在 HTTP 請求時,返回原始請求體數據字節,默認爲 true (GET or HEAD or 上傳文件請求除外)。CopyRequestBody = true
beego.BConfig.CopyRequestBody = true
網絡
EnableGzip 是否開啓 gzip 支持,默認爲 false 不支持 gzip,一旦開啓了 gzip,那麼在模板輸出的內容會進行 gzip 或者 zlib 壓縮,根據用戶的 Accept-Encoding 來判斷。web項目應該設置爲true,經過流量的壓縮加速網站開啓速度,以及在有限的帶寬條件下,支持更多人的訪問EnableGzip = false
beego.BConfig.EnableGzip = false
Gzip容許用戶自定義壓縮級別、壓縮長度閾值和針對請求類型壓縮:session
gzipCompressLevel = 9
,取值爲 1~9,默認爲 1(最快壓縮)gzipMinLength = 256
,當原始內容長度大於此閾值時纔開啓壓縮,默認爲 20B(ngnix默認長度)includedMethods = get;post
,針對哪些請求類型進行壓縮,默認只針對 GET 請求壓縮MaxMemory 文件上傳默認內存緩存大小,默認值是 1 << 26(64M)。MaxMemory = 1 << 26
beego.BConfig.MaxMemory = 1 << 26
框架
EnableErrorsShow 是否顯示系統錯誤信息,默認爲 true。EnableErrorsShow = true
beego.BConfig.EnableErrorsShow = true
tcp
EnableErrorsRender 是否將錯誤信息進行渲染,默認值爲 true,即出錯會提示友好的出錯頁面,對於 API 類型的應用可能須要將該選項設置爲 false 以阻止在 dev 模式下沒必要要的模板渲染信息返回。EnableErrorsRender = true
beego.BConfig.EnableErrorsRender = true
#Web配置 for Api AutoRender = false EnableDocs = true FlashName = API_FLASH FlashSeperator = APIFLASH #==配合swagger使用start== DirectoryIndex = true StaticDir = swagger #==配合swagger使用end== StaticExtensionsToGzip = .css, .js TemplateLeft = {{ TemplateRight = }} ViewsPath = views EnableXSRF = false XSRFKEY = beegoxsrf XSRFExpire = 0
AutoRender = true
beego.BConfig.WebConfig.AutoRender = true
EnableDocs = false
beego.BConfig.WebConfig.EnableDocs = false
FlashName = BEEGO_FLASH
beego.BConfig.WebConfig.FlashName = "BEEGO_FLASH"
FlashSeperator = BEEGOFLASH
beego.BConfig.WebConfig.FlashSeperator = "BEEGOFLASH"
DirectoryIndex = false
beego.BConfig.WebConfig.DirectoryIndex = false
StaticDir = swagger
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
StaticExtensionsToGzip = .css, .js
beego.BConfig.WebConfig.StaticExtensionsToGzip = []string{".css", ".js"}
TemplateLeft = {{
beego.BConfig.WebConfig.TemplateLeft="{{"
TemplateRight = }}
beego.BConfig.WebConfig.TemplateRight = "}}"
ViewsPath = views
beego.BConfig.WebConfig.ViewsPath = "views"
EnableXSRF = false
beego.BConfig.WebConfig.EnableXSRF = false
XSRFKEY = beegoxsrf
beego.BConfig.WebConfig.XSRFKEY = "beegoxsrf"
XSRFExpire = 0
beego.BConfig.WebConfig.XSRFExpire = 0
#listener配置 Graceful = false ServerTimeOut = 30 ListenTCP4 = tcp4 EnableHTTP = true HTTPAddr = HTTPPort = 8080 EnableHTTPS = false HTTPSAddr = HTTPSPort = 10443 HTTPSCertFile = conf/ssl.crt HTTPSKeyFile= conf/ssl.key EnableAdmin = true AdminAddr = localhost AdminPort = 8088 EnableFcgi = false EnableStdIo = false
Graceful = false
beego.BConfig.Listen.Graceful = false
ServerTimeOut = 0
beego.BConfig.Listen.ServerTimeOut = 0
ListenTCP4 = tcp4
beego.BConfig.Listen.ListenTCP4 = "tcp4"
EnableHTTP = true
beego.BConfig.Listen.EnableHTTP = true
HTTPAddr =
beego.BConfig.Listen.HTTPAddr = ""
HTTPPort = 8080
beego.BConfig.Listen.HTTPPort = 8080
EnableHTTPS = false
beego.BConfig.Listen.EnableHTTPS = false
HTTPSAddr =
beego.BConfig.Listen.HTTPSAddr = ""
HTTPSPort = 10443
beego.BConfig.Listen.HTTPSPort = 10443
HTTPSCertFile = conf/ssl.crt
beego.BConfig.Listen.HTTPSCertFile = "conf/ssl.crt"
HTTPSKeyFile= conf/ssl.key
beego.BConfig.Listen.HTTPSKeyFile= "conf/ssl.key"
EnableAdmin = false
beego.BConfig.Listen.EnableAdmin = false
AdminAddr = localhost
beego.BConfig.Listen.AdminAddr = "localhost"
AdminPort = 8088
beego.BConfig.Listen.AdminPort = 8088
EnableFcgi = false
beego.BConfig.Listen.EnableFcgi = false
EnableStdIo = false
beego.BConfig.Listen.EnableStdIo = false
#Session配置 SessionOn = false SessionProvider = SessionName = beegosessionID SessionGCMaxLifetime = 3600 SessionCookieLifeTime = 3600 SessionAutoSetCookie = true SessionDomain =
SessionOn = false
beego.BConfig.WebConfig.Session.SessionOn = false
SessionProvider =
beego.BConfig.WebConfig.Session.SessionProvider = ""
SessionName = beegosessionID
beego.BConfig.WebConfig.Session.SessionName = "beegosessionID"
SessionGCMaxLifetime = 3600
beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 3600
SessionCookieLifeTime = 3600
beego.BConfig.WebConfig.Session.SessionCookieLifeTime = 3600
SessionAutoSetCookie = true
beego.BConfig.WebConfig.Session.SessionAutoSetCookie = true
SessionDomain =
beego.BConfig.WebConfig.Session.SessionDomain = ""
beego.BConfig.Log.AccessLogs = false
beego.BConfig.Log.FileLineNum = true
beego.BConfig.Log.Outputs = map[string]string{"console": ""}
beego.BConfig.Log.Outputs["console"] = ""