mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 18:30:56 +00:00
make golint happy and also make the config readable
This commit is contained in:
parent
152127c2af
commit
f28a941e26
28
admin.go
28
admin.go
@ -101,11 +101,11 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
|
|||||||
m["AppConfigPath"] = AppConfigPath
|
m["AppConfigPath"] = AppConfigPath
|
||||||
m["StaticDir"] = StaticDir
|
m["StaticDir"] = StaticDir
|
||||||
m["StaticExtensionsToGzip"] = StaticExtensionsToGzip
|
m["StaticExtensionsToGzip"] = StaticExtensionsToGzip
|
||||||
m["HttpAddr"] = HttpAddr
|
m["HTTPAddr"] = HTTPAddr
|
||||||
m["HttpPort"] = HttpPort
|
m["HTTPPort"] = HTTPPort
|
||||||
m["HttpTLS"] = EnableHttpTLS
|
m["HTTPTLS"] = EnableHTTPTLS
|
||||||
m["HttpCertFile"] = HttpCertFile
|
m["HTTPCertFile"] = HTTPCertFile
|
||||||
m["HttpKeyFile"] = HttpKeyFile
|
m["HTTPKeyFile"] = HTTPKeyFile
|
||||||
m["RecoverPanic"] = RecoverPanic
|
m["RecoverPanic"] = RecoverPanic
|
||||||
m["AutoRender"] = AutoRender
|
m["AutoRender"] = AutoRender
|
||||||
m["ViewsPath"] = ViewsPath
|
m["ViewsPath"] = ViewsPath
|
||||||
@ -114,14 +114,14 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
|
|||||||
m["SessionProvider"] = SessionProvider
|
m["SessionProvider"] = SessionProvider
|
||||||
m["SessionName"] = SessionName
|
m["SessionName"] = SessionName
|
||||||
m["SessionGCMaxLifetime"] = SessionGCMaxLifetime
|
m["SessionGCMaxLifetime"] = SessionGCMaxLifetime
|
||||||
m["SessionSavePath"] = SessionSavePath
|
m["SessionProviderConfig"] = SessionProviderConfig
|
||||||
m["SessionCookieLifeTime"] = SessionCookieLifeTime
|
m["SessionCookieLifeTime"] = SessionCookieLifeTime
|
||||||
m["UseFcgi"] = UseFcgi
|
m["EnabelFcgi"] = EnabelFcgi
|
||||||
m["MaxMemory"] = MaxMemory
|
m["MaxMemory"] = MaxMemory
|
||||||
m["EnableGzip"] = EnableGzip
|
m["EnableGzip"] = EnableGzip
|
||||||
m["DirectoryIndex"] = DirectoryIndex
|
m["DirectoryIndex"] = DirectoryIndex
|
||||||
m["HttpServerTimeOut"] = HttpServerTimeOut
|
m["HTTPServerTimeOut"] = HTTPServerTimeOut
|
||||||
m["ErrorsShow"] = ErrorsShow
|
m["EnableErrorsShow"] = EnableErrorsShow
|
||||||
m["XSRFKEY"] = XSRFKEY
|
m["XSRFKEY"] = XSRFKEY
|
||||||
m["EnableXSRF"] = EnableXSRF
|
m["EnableXSRF"] = EnableXSRF
|
||||||
m["XSRFExpire"] = XSRFExpire
|
m["XSRFExpire"] = XSRFExpire
|
||||||
@ -130,8 +130,8 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
|
|||||||
m["TemplateRight"] = TemplateRight
|
m["TemplateRight"] = TemplateRight
|
||||||
m["BeegoServerName"] = BeegoServerName
|
m["BeegoServerName"] = BeegoServerName
|
||||||
m["EnableAdmin"] = EnableAdmin
|
m["EnableAdmin"] = EnableAdmin
|
||||||
m["AdminHttpAddr"] = AdminHttpAddr
|
m["AdminHTTPAddr"] = AdminHTTPAddr
|
||||||
m["AdminHttpPort"] = AdminHttpPort
|
m["AdminHTTPPort"] = AdminHTTPPort
|
||||||
|
|
||||||
tmpl := template.Must(template.New("dashboard").Parse(dashboardTpl))
|
tmpl := template.Must(template.New("dashboard").Parse(dashboardTpl))
|
||||||
tmpl = template.Must(tmpl.Parse(configTpl))
|
tmpl = template.Must(tmpl.Parse(configTpl))
|
||||||
@ -451,10 +451,10 @@ func (admin *adminApp) Run() {
|
|||||||
if len(toolbox.AdminTaskList) > 0 {
|
if len(toolbox.AdminTaskList) > 0 {
|
||||||
toolbox.StartTask()
|
toolbox.StartTask()
|
||||||
}
|
}
|
||||||
addr := AdminHttpAddr
|
addr := AdminHTTPAddr
|
||||||
|
|
||||||
if AdminHttpPort != 0 {
|
if AdminHTTPPort != 0 {
|
||||||
addr = fmt.Sprintf("%s:%d", AdminHttpAddr, AdminHttpPort)
|
addr = fmt.Sprintf("%s:%d", AdminHTTPAddr, AdminHTTPPort)
|
||||||
}
|
}
|
||||||
for p, f := range admin.routers {
|
for p, f := range admin.routers {
|
||||||
http.Handle(p, f)
|
http.Handle(p, f)
|
||||||
|
44
app.go
44
app.go
@ -52,10 +52,10 @@ func NewApp() *App {
|
|||||||
|
|
||||||
// Run beego application.
|
// Run beego application.
|
||||||
func (app *App) Run() {
|
func (app *App) Run() {
|
||||||
addr := HttpAddr
|
addr := HTTPAddr
|
||||||
|
|
||||||
if HttpPort != 0 {
|
if HTTPPort != 0 {
|
||||||
addr = fmt.Sprintf("%s:%d", HttpAddr, HttpPort)
|
addr = fmt.Sprintf("%s:%d", HTTPAddr, HTTPPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -64,8 +64,8 @@ func (app *App) Run() {
|
|||||||
)
|
)
|
||||||
endRunning := make(chan bool, 1)
|
endRunning := make(chan bool, 1)
|
||||||
|
|
||||||
if UseFcgi {
|
if EnabelFcgi {
|
||||||
if UseStdIo {
|
if EnableStdIo {
|
||||||
err = fcgi.Serve(nil, app.Handlers) // standard I/O
|
err = fcgi.Serve(nil, app.Handlers) // standard I/O
|
||||||
if err == nil {
|
if err == nil {
|
||||||
BeeLogger.Info("Use FCGI via standard I/O")
|
BeeLogger.Info("Use FCGI via standard I/O")
|
||||||
@ -73,7 +73,7 @@ func (app *App) Run() {
|
|||||||
BeeLogger.Info("Cannot use FCGI via standard I/O", err)
|
BeeLogger.Info("Cannot use FCGI via standard I/O", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if HttpPort == 0 {
|
if HTTPPort == 0 {
|
||||||
// remove the Socket file before start
|
// remove the Socket file before start
|
||||||
if utils.FileExists(addr) {
|
if utils.FileExists(addr) {
|
||||||
os.Remove(addr)
|
os.Remove(addr)
|
||||||
@ -91,18 +91,18 @@ func (app *App) Run() {
|
|||||||
if Graceful {
|
if Graceful {
|
||||||
app.Server.Addr = addr
|
app.Server.Addr = addr
|
||||||
app.Server.Handler = app.Handlers
|
app.Server.Handler = app.Handlers
|
||||||
app.Server.ReadTimeout = time.Duration(HttpServerTimeOut) * time.Second
|
app.Server.ReadTimeout = time.Duration(HTTPServerTimeOut) * time.Second
|
||||||
app.Server.WriteTimeout = time.Duration(HttpServerTimeOut) * time.Second
|
app.Server.WriteTimeout = time.Duration(HTTPServerTimeOut) * time.Second
|
||||||
if EnableHttpTLS {
|
if EnableHTTPTLS {
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(20 * time.Microsecond)
|
time.Sleep(20 * time.Microsecond)
|
||||||
if HttpsPort != 0 {
|
if HTTPSPort != 0 {
|
||||||
addr = fmt.Sprintf("%s:%d", HttpAddr, HttpsPort)
|
addr = fmt.Sprintf("%s:%d", HTTPAddr, HTTPSPort)
|
||||||
app.Server.Addr = addr
|
app.Server.Addr = addr
|
||||||
}
|
}
|
||||||
server := grace.NewServer(addr, app.Handlers)
|
server := grace.NewServer(addr, app.Handlers)
|
||||||
server.Server = app.Server
|
server.Server = app.Server
|
||||||
err := server.ListenAndServeTLS(HttpCertFile, HttpKeyFile)
|
err := server.ListenAndServeTLS(HTTPCertFile, HTTPKeyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
BeeLogger.Critical("ListenAndServeTLS: ", err, fmt.Sprintf("%d", os.Getpid()))
|
BeeLogger.Critical("ListenAndServeTLS: ", err, fmt.Sprintf("%d", os.Getpid()))
|
||||||
time.Sleep(100 * time.Microsecond)
|
time.Sleep(100 * time.Microsecond)
|
||||||
@ -110,11 +110,11 @@ func (app *App) Run() {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
if EnableHttpListen {
|
if EnableHTTPListen {
|
||||||
go func() {
|
go func() {
|
||||||
server := grace.NewServer(addr, app.Handlers)
|
server := grace.NewServer(addr, app.Handlers)
|
||||||
server.Server = app.Server
|
server.Server = app.Server
|
||||||
if ListenTCP4 && HttpAddr == "" {
|
if ListenTCP4 && HTTPAddr == "" {
|
||||||
server.Network = "tcp4"
|
server.Network = "tcp4"
|
||||||
}
|
}
|
||||||
err := server.ListenAndServe()
|
err := server.ListenAndServe()
|
||||||
@ -128,17 +128,17 @@ func (app *App) Run() {
|
|||||||
} else {
|
} else {
|
||||||
app.Server.Addr = addr
|
app.Server.Addr = addr
|
||||||
app.Server.Handler = app.Handlers
|
app.Server.Handler = app.Handlers
|
||||||
app.Server.ReadTimeout = time.Duration(HttpServerTimeOut) * time.Second
|
app.Server.ReadTimeout = time.Duration(HTTPServerTimeOut) * time.Second
|
||||||
app.Server.WriteTimeout = time.Duration(HttpServerTimeOut) * time.Second
|
app.Server.WriteTimeout = time.Duration(HTTPServerTimeOut) * time.Second
|
||||||
|
|
||||||
if EnableHttpTLS {
|
if EnableHTTPTLS {
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(20 * time.Microsecond)
|
time.Sleep(20 * time.Microsecond)
|
||||||
if HttpsPort != 0 {
|
if HTTPSPort != 0 {
|
||||||
app.Server.Addr = fmt.Sprintf("%s:%d", HttpAddr, HttpsPort)
|
app.Server.Addr = fmt.Sprintf("%s:%d", HTTPAddr, HTTPSPort)
|
||||||
}
|
}
|
||||||
BeeLogger.Info("https server Running on %s", app.Server.Addr)
|
BeeLogger.Info("https server Running on %s", app.Server.Addr)
|
||||||
err := app.Server.ListenAndServeTLS(HttpCertFile, HttpKeyFile)
|
err := app.Server.ListenAndServeTLS(HTTPCertFile, HTTPKeyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
BeeLogger.Critical("ListenAndServeTLS: ", err)
|
BeeLogger.Critical("ListenAndServeTLS: ", err)
|
||||||
time.Sleep(100 * time.Microsecond)
|
time.Sleep(100 * time.Microsecond)
|
||||||
@ -147,11 +147,11 @@ func (app *App) Run() {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
if EnableHttpListen {
|
if EnableHTTPListen {
|
||||||
go func() {
|
go func() {
|
||||||
app.Server.Addr = addr
|
app.Server.Addr = addr
|
||||||
BeeLogger.Info("http server Running on %s", app.Server.Addr)
|
BeeLogger.Info("http server Running on %s", app.Server.Addr)
|
||||||
if ListenTCP4 && HttpAddr == "" {
|
if ListenTCP4 && HTTPAddr == "" {
|
||||||
ln, err := net.Listen("tcp4", app.Server.Addr)
|
ln, err := net.Listen("tcp4", app.Server.Addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
BeeLogger.Critical("ListenAndServe: ", err)
|
BeeLogger.Critical("ListenAndServe: ", err)
|
||||||
|
4
beego.go
4
beego.go
@ -48,10 +48,10 @@ func Run(params ...string) {
|
|||||||
if len(params) > 0 && params[0] != "" {
|
if len(params) > 0 && params[0] != "" {
|
||||||
strs := strings.Split(params[0], ":")
|
strs := strings.Split(params[0], ":")
|
||||||
if len(strs) > 0 && strs[0] != "" {
|
if len(strs) > 0 && strs[0] != "" {
|
||||||
HttpAddr = strs[0]
|
HTTPAddr = strs[0]
|
||||||
}
|
}
|
||||||
if len(strs) > 1 && strs[1] != "" {
|
if len(strs) > 1 && strs[1] != "" {
|
||||||
HttpPort, _ = strconv.Atoi(strs[1])
|
HTTPPort, _ = strconv.Atoi(strs[1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
235
config.go
235
config.go
@ -29,59 +29,115 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
AppName string
|
// AccessLogs represent whether output the access logs, default is false
|
||||||
AppPath string
|
AccessLogs bool
|
||||||
workPath string
|
// AdminHTTPAddr is address for admin
|
||||||
AppConfigPath string
|
AdminHTTPAddr string
|
||||||
StaticDir map[string]string
|
// AdminHTTPPort is listens port for admin
|
||||||
TemplateCache map[string]*template.Template // template caching map
|
AdminHTTPPort int
|
||||||
StaticExtensionsToGzip []string // files with should be compressed with gzip (.js,.css,etc)
|
// AppConfig is the instance of Config, store the config information from file
|
||||||
EnableHttpListen bool
|
AppConfig *beegoAppConfig
|
||||||
HttpAddr string
|
// AppName represent Application name, always the project folder name
|
||||||
HttpPort int
|
AppName string
|
||||||
ListenTCP4 bool
|
// AppPath is the path to the application
|
||||||
EnableHttpTLS bool
|
AppPath string
|
||||||
HttpsPort int
|
// AppConfigPath is the path to the config files
|
||||||
HttpCertFile string
|
AppConfigPath string
|
||||||
HttpKeyFile string
|
// AppConfigProvider is the provider for the config, default is ini
|
||||||
RecoverPanic bool // flag of auto recover panic
|
AppConfigProvider string
|
||||||
AutoRender bool // flag of render template automatically
|
// AutoRender is a flag of render template automatically. It's always turn off in API application
|
||||||
ViewsPath string
|
// default is true
|
||||||
AppConfig *beegoAppConfig
|
AutoRender bool
|
||||||
RunMode string // run mode, "dev" or "prod"
|
// BeegoServerName exported in response header.
|
||||||
GlobalSessions *session.Manager // global session mananger
|
BeegoServerName string
|
||||||
SessionOn bool // flag of starting session auto. default is false.
|
// CopyRequestBody is just useful for raw request body in context. default is false
|
||||||
SessionProvider string // default session provider, memory, mysql , redis ,etc.
|
CopyRequestBody bool
|
||||||
SessionName string // the cookie name when saving session id into cookie.
|
// DirectoryIndex wheather display directory index. default is false.
|
||||||
SessionGCMaxLifetime int64 // session gc time for auto cleaning expired session.
|
DirectoryIndex bool
|
||||||
SessionSavePath string // if use mysql/redis/file provider, define save path to connection info.
|
// EnableAdmin means turn on admin module to log every request info.
|
||||||
SessionCookieLifeTime int // the life time of session id in cookie.
|
EnableAdmin bool
|
||||||
SessionAutoSetCookie bool // auto setcookie
|
// EnableDocs enable generate docs & server docs API Swagger
|
||||||
SessionDomain string // the cookie domain default is empty
|
EnableDocs bool
|
||||||
UseFcgi bool
|
// EnableErrorsShow wheather show errors in page. if true, show error and trace info in page rendered with error template.
|
||||||
UseStdIo bool
|
EnableErrorsShow bool
|
||||||
MaxMemory int64
|
// EnabelFcgi turn on the fcgi Listen, default is false
|
||||||
EnableGzip bool // flag of enable gzip
|
EnabelFcgi bool
|
||||||
DirectoryIndex bool // flag of display directory index. default is false.
|
// EnableGzip means gzip the response
|
||||||
HttpServerTimeOut int64
|
EnableGzip bool
|
||||||
ErrorsShow bool // flag of show errors in page. if true, show error and trace info in page rendered with error template.
|
// EnableHTTPListen represent whether turn on the HTTP, default is true
|
||||||
XSRFKEY string // xsrf hash salt string.
|
EnableHTTPListen bool
|
||||||
EnableXSRF bool // flag of enable xsrf.
|
// EnableHTTPTLS represent whether turn on the HTTPS, default is true
|
||||||
XSRFExpire int // the expiry of xsrf value.
|
EnableHTTPTLS bool
|
||||||
CopyRequestBody bool // flag of copy raw request body in context.
|
// EnableStdIo works with EnabelFcgi Use FCGI via standard I/O
|
||||||
TemplateLeft string
|
EnableStdIo bool
|
||||||
TemplateRight string
|
// EnableXSRF whether turn on xsrf. default is false
|
||||||
BeegoServerName string // beego server name exported in response header.
|
EnableXSRF bool
|
||||||
EnableAdmin bool // flag of enable admin module to log every request info.
|
// FlashName is the name of the flash variable found in response header and cookie
|
||||||
AdminHttpAddr string // http server configurations for admin module.
|
FlashName string
|
||||||
AdminHttpPort int
|
// FlashSeperator used to seperate flash key:value, default is BEEGOFLASH
|
||||||
FlashName string // name of the flash variable found in response header and cookie
|
FlashSeperator string
|
||||||
FlashSeperator string // used to seperate flash key:value
|
// GlobalSessions is the instance for the session manager
|
||||||
AppConfigProvider string // config provider
|
GlobalSessions *session.Manager
|
||||||
EnableDocs bool // enable generate docs & server docs API Swagger
|
// Graceful means use graceful module to start the server
|
||||||
RouterCaseSensitive bool // router case sensitive default is true
|
Graceful bool
|
||||||
AccessLogs bool // print access logs, default is false
|
// workPath is always the same as AppPath, but sometime when it started with other
|
||||||
Graceful bool // use graceful start the server
|
// program, like supervisor
|
||||||
|
workPath string
|
||||||
|
// ListenTCP4 represent only Listen in TCP4, default is false
|
||||||
|
ListenTCP4 bool
|
||||||
|
// MaxMemory The whole request body is parsed and up to a total of maxMemory
|
||||||
|
// bytes of its file parts are stored in memory, with the remainder stored on disk in temporary files
|
||||||
|
MaxMemory int64
|
||||||
|
// HTTPAddr is the TCP network address addr for HTTP
|
||||||
|
HTTPAddr string
|
||||||
|
// HTTPPort is listens port for HTTP
|
||||||
|
HTTPPort int
|
||||||
|
// HTTPSPort is listens port for HTTPS
|
||||||
|
HTTPSPort int
|
||||||
|
// HTTPCertFile is the path to certificate file
|
||||||
|
HTTPCertFile string
|
||||||
|
// HTTPKeyFile is the path to private key file
|
||||||
|
HTTPKeyFile string
|
||||||
|
// HTTPServerTimeOut HTTP server timeout. default is 0, no timeout
|
||||||
|
HTTPServerTimeOut int64
|
||||||
|
// RecoverPanic is a flag for auto recover panic, default is true
|
||||||
|
RecoverPanic bool
|
||||||
|
// RouterCaseSensitive means whether router case sensitive, default is true
|
||||||
|
RouterCaseSensitive bool
|
||||||
|
// RunMode represent the staging, "dev" or "prod"
|
||||||
|
RunMode string
|
||||||
|
// SessionOn means whether turn on the session auto when application started. default is false.
|
||||||
|
SessionOn bool
|
||||||
|
// SessionProvider means session provider, e.q memory, mysql, redis,etc.
|
||||||
|
SessionProvider string
|
||||||
|
// SessionName is the cookie name when saving session id into cookie.
|
||||||
|
SessionName string
|
||||||
|
// SessionGCMaxLifetime for auto cleaning expired session.
|
||||||
|
SessionGCMaxLifetime int64
|
||||||
|
// SessionProviderConfig is for the provider config, define save path or connection info.
|
||||||
|
SessionProviderConfig string
|
||||||
|
// SessionCookieLifeTime means the life time of session id in cookie.
|
||||||
|
SessionCookieLifeTime int
|
||||||
|
// SessionAutoSetCookie auto setcookie
|
||||||
|
SessionAutoSetCookie bool
|
||||||
|
// SessionDomain means the cookie domain default is empty
|
||||||
|
SessionDomain string
|
||||||
|
// StaticDir store the static path, key is path, value is the folder
|
||||||
|
StaticDir map[string]string
|
||||||
|
// StaticExtensionsToGzip stores the extensions which need to gzip(.js,.css,etc)
|
||||||
|
StaticExtensionsToGzip []string
|
||||||
|
// TemplateCache store the caching template
|
||||||
|
TemplateCache map[string]*template.Template
|
||||||
|
// TemplateLeft left delimiter
|
||||||
|
TemplateLeft string
|
||||||
|
// TemplateRight right delimiter
|
||||||
|
TemplateRight string
|
||||||
|
// ViewsPath means the template folder
|
||||||
|
ViewsPath string
|
||||||
|
// XSRFKEY xsrf hash salt string.
|
||||||
|
XSRFKEY string
|
||||||
|
// XSRFExpire is the expiry of xsrf value.
|
||||||
|
XSRFExpire int
|
||||||
)
|
)
|
||||||
|
|
||||||
type beegoAppConfig struct {
|
type beegoAppConfig struct {
|
||||||
@ -239,12 +295,12 @@ func init() {
|
|||||||
TemplateCache = make(map[string]*template.Template)
|
TemplateCache = make(map[string]*template.Template)
|
||||||
|
|
||||||
// set this to 0.0.0.0 to make this app available to externally
|
// set this to 0.0.0.0 to make this app available to externally
|
||||||
EnableHttpListen = true //default enable http Listen
|
EnableHTTPListen = true //default enable http Listen
|
||||||
|
|
||||||
HttpAddr = ""
|
HTTPAddr = ""
|
||||||
HttpPort = 8080
|
HTTPPort = 8080
|
||||||
|
|
||||||
HttpsPort = 10443
|
HTTPSPort = 10443
|
||||||
|
|
||||||
AppName = "beego"
|
AppName = "beego"
|
||||||
|
|
||||||
@ -260,20 +316,15 @@ func init() {
|
|||||||
SessionProvider = "memory"
|
SessionProvider = "memory"
|
||||||
SessionName = "beegosessionID"
|
SessionName = "beegosessionID"
|
||||||
SessionGCMaxLifetime = 3600
|
SessionGCMaxLifetime = 3600
|
||||||
SessionSavePath = ""
|
SessionProviderConfig = ""
|
||||||
SessionCookieLifeTime = 0 //set cookie default is the brower life
|
SessionCookieLifeTime = 0 //set cookie default is the brower life
|
||||||
SessionAutoSetCookie = true
|
SessionAutoSetCookie = true
|
||||||
|
|
||||||
UseFcgi = false
|
|
||||||
UseStdIo = false
|
|
||||||
|
|
||||||
MaxMemory = 1 << 26 //64MB
|
MaxMemory = 1 << 26 //64MB
|
||||||
|
|
||||||
EnableGzip = false
|
HTTPServerTimeOut = 0
|
||||||
|
|
||||||
HttpServerTimeOut = 0
|
EnableErrorsShow = true
|
||||||
|
|
||||||
ErrorsShow = true
|
|
||||||
|
|
||||||
XSRFKEY = "beegoxsrf"
|
XSRFKEY = "beegoxsrf"
|
||||||
XSRFExpire = 0
|
XSRFExpire = 0
|
||||||
@ -284,8 +335,8 @@ func init() {
|
|||||||
BeegoServerName = "beegoServer:" + VERSION
|
BeegoServerName = "beegoServer:" + VERSION
|
||||||
|
|
||||||
EnableAdmin = false
|
EnableAdmin = false
|
||||||
AdminHttpAddr = "127.0.0.1"
|
AdminHTTPAddr = "127.0.0.1"
|
||||||
AdminHttpPort = 8088
|
AdminHTTPPort = 8088
|
||||||
|
|
||||||
FlashName = "BEEGO_FLASH"
|
FlashName = "BEEGO_FLASH"
|
||||||
FlashSeperator = "BEEGOFLASH"
|
FlashSeperator = "BEEGOFLASH"
|
||||||
@ -326,18 +377,18 @@ func ParseConfig() (err error) {
|
|||||||
RunMode = runmode
|
RunMode = runmode
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpAddr = AppConfig.String("HttpAddr")
|
HTTPAddr = AppConfig.String("HTTPAddr")
|
||||||
|
|
||||||
if v, err := AppConfig.Int("HttpPort"); err == nil {
|
if v, err := AppConfig.Int("HTTPPort"); err == nil {
|
||||||
HttpPort = v
|
HTTPPort = v
|
||||||
}
|
}
|
||||||
|
|
||||||
if v, err := AppConfig.Bool("ListenTCP4"); err == nil {
|
if v, err := AppConfig.Bool("ListenTCP4"); err == nil {
|
||||||
ListenTCP4 = v
|
ListenTCP4 = v
|
||||||
}
|
}
|
||||||
|
|
||||||
if v, err := AppConfig.Bool("EnableHttpListen"); err == nil {
|
if v, err := AppConfig.Bool("EnableHTTPListen"); err == nil {
|
||||||
EnableHttpListen = v
|
EnableHTTPListen = v
|
||||||
}
|
}
|
||||||
|
|
||||||
if maxmemory, err := AppConfig.Int64("MaxMemory"); err == nil {
|
if maxmemory, err := AppConfig.Int64("MaxMemory"); err == nil {
|
||||||
@ -372,8 +423,8 @@ func ParseConfig() (err error) {
|
|||||||
SessionName = sessName
|
SessionName = sessName
|
||||||
}
|
}
|
||||||
|
|
||||||
if sesssavepath := AppConfig.String("SessionSavePath"); sesssavepath != "" {
|
if sessProvConfig := AppConfig.String("SessionProviderConfig"); sessProvConfig != "" {
|
||||||
SessionSavePath = sesssavepath
|
SessionProviderConfig = sessProvConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
if sessMaxLifeTime, err := AppConfig.Int64("SessionGCMaxLifetime"); err == nil && sessMaxLifeTime != 0 {
|
if sessMaxLifeTime, err := AppConfig.Int64("SessionGCMaxLifetime"); err == nil && sessMaxLifeTime != 0 {
|
||||||
@ -384,8 +435,8 @@ func ParseConfig() (err error) {
|
|||||||
SessionCookieLifeTime = sesscookielifetime
|
SessionCookieLifeTime = sesscookielifetime
|
||||||
}
|
}
|
||||||
|
|
||||||
if usefcgi, err := AppConfig.Bool("UseFcgi"); err == nil {
|
if enabelFcgi, err := AppConfig.Bool("EnabelFcgi"); err == nil {
|
||||||
UseFcgi = usefcgi
|
EnabelFcgi = enabelFcgi
|
||||||
}
|
}
|
||||||
|
|
||||||
if enablegzip, err := AppConfig.Bool("EnableGzip"); err == nil {
|
if enablegzip, err := AppConfig.Bool("EnableGzip"); err == nil {
|
||||||
@ -396,12 +447,12 @@ func ParseConfig() (err error) {
|
|||||||
DirectoryIndex = directoryindex
|
DirectoryIndex = directoryindex
|
||||||
}
|
}
|
||||||
|
|
||||||
if timeout, err := AppConfig.Int64("HttpServerTimeOut"); err == nil {
|
if timeout, err := AppConfig.Int64("HTTPServerTimeOut"); err == nil {
|
||||||
HttpServerTimeOut = timeout
|
HTTPServerTimeOut = timeout
|
||||||
}
|
}
|
||||||
|
|
||||||
if errorsshow, err := AppConfig.Bool("ErrorsShow"); err == nil {
|
if errorsshow, err := AppConfig.Bool("EnableErrorsShow"); err == nil {
|
||||||
ErrorsShow = errorsshow
|
EnableErrorsShow = errorsshow
|
||||||
}
|
}
|
||||||
|
|
||||||
if copyrequestbody, err := AppConfig.Bool("CopyRequestBody"); err == nil {
|
if copyrequestbody, err := AppConfig.Bool("CopyRequestBody"); err == nil {
|
||||||
@ -428,20 +479,20 @@ func ParseConfig() (err error) {
|
|||||||
TemplateRight = tplright
|
TemplateRight = tplright
|
||||||
}
|
}
|
||||||
|
|
||||||
if httptls, err := AppConfig.Bool("EnableHttpTLS"); err == nil {
|
if httptls, err := AppConfig.Bool("EnableHTTPTLS"); err == nil {
|
||||||
EnableHttpTLS = httptls
|
EnableHTTPTLS = httptls
|
||||||
}
|
}
|
||||||
|
|
||||||
if httpsport, err := AppConfig.Int("HttpsPort"); err == nil {
|
if httpsport, err := AppConfig.Int("HTTPSPort"); err == nil {
|
||||||
HttpsPort = httpsport
|
HTTPSPort = httpsport
|
||||||
}
|
}
|
||||||
|
|
||||||
if certfile := AppConfig.String("HttpCertFile"); certfile != "" {
|
if certfile := AppConfig.String("HTTPCertFile"); certfile != "" {
|
||||||
HttpCertFile = certfile
|
HTTPCertFile = certfile
|
||||||
}
|
}
|
||||||
|
|
||||||
if keyfile := AppConfig.String("HttpKeyFile"); keyfile != "" {
|
if keyfile := AppConfig.String("HTTPKeyFile"); keyfile != "" {
|
||||||
HttpKeyFile = keyfile
|
HTTPKeyFile = keyfile
|
||||||
}
|
}
|
||||||
|
|
||||||
if serverName := AppConfig.String("BeegoServerName"); serverName != "" {
|
if serverName := AppConfig.String("BeegoServerName"); serverName != "" {
|
||||||
@ -491,12 +542,12 @@ func ParseConfig() (err error) {
|
|||||||
EnableAdmin = enableadmin
|
EnableAdmin = enableadmin
|
||||||
}
|
}
|
||||||
|
|
||||||
if adminhttpaddr := AppConfig.String("AdminHttpAddr"); adminhttpaddr != "" {
|
if adminhttpaddr := AppConfig.String("AdminHTTPAddr"); adminhttpaddr != "" {
|
||||||
AdminHttpAddr = adminhttpaddr
|
AdminHTTPAddr = adminhttpaddr
|
||||||
}
|
}
|
||||||
|
|
||||||
if adminhttpport, err := AppConfig.Int("AdminHttpPort"); err == nil {
|
if adminhttpport, err := AppConfig.Int("AdminHTTPPort"); err == nil {
|
||||||
AdminHttpPort = adminhttpport
|
AdminHTTPPort = adminhttpport
|
||||||
}
|
}
|
||||||
|
|
||||||
if enabledocs, err := AppConfig.Bool("EnableDocs"); err == nil {
|
if enabledocs, err := AppConfig.Bool("EnableDocs"); err == nil {
|
||||||
|
4
hooks.go
4
hooks.go
@ -65,8 +65,8 @@ func registerSession() error {
|
|||||||
if sessionConfig == "" {
|
if sessionConfig == "" {
|
||||||
sessionConfig = `{"cookieName":"` + SessionName + `",` +
|
sessionConfig = `{"cookieName":"` + SessionName + `",` +
|
||||||
`"gclifetime":` + strconv.FormatInt(SessionGCMaxLifetime, 10) + `,` +
|
`"gclifetime":` + strconv.FormatInt(SessionGCMaxLifetime, 10) + `,` +
|
||||||
`"providerConfig":"` + filepath.ToSlash(SessionSavePath) + `",` +
|
`"providerConfig":"` + filepath.ToSlash(SessionProviderConfig) + `",` +
|
||||||
`"secure":` + strconv.FormatBool(EnableHttpTLS) + `,` +
|
`"secure":` + strconv.FormatBool(EnableHTTPTLS) + `,` +
|
||||||
`"enableSetCookie":` + strconv.FormatBool(SessionAutoSetCookie) + `,` +
|
`"enableSetCookie":` + strconv.FormatBool(SessionAutoSetCookie) + `,` +
|
||||||
`"domain":"` + SessionDomain + `",` +
|
`"domain":"` + SessionDomain + `",` +
|
||||||
`"cookieLifeTime":` + strconv.Itoa(SessionCookieLifeTime) + `}`
|
`"cookieLifeTime":` + strconv.Itoa(SessionCookieLifeTime) + `}`
|
||||||
|
@ -869,7 +869,7 @@ func (p *ControllerRegister) recoverPanic(context *beecontext.Context) {
|
|||||||
if !RecoverPanic {
|
if !RecoverPanic {
|
||||||
panic(err)
|
panic(err)
|
||||||
} else {
|
} else {
|
||||||
if ErrorsShow {
|
if EnableErrorsShow {
|
||||||
if _, ok := ErrorMaps[fmt.Sprint(err)]; ok {
|
if _, ok := ErrorMaps[fmt.Sprint(err)]; ok {
|
||||||
exception(fmt.Sprint(err), context)
|
exception(fmt.Sprint(err), context)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user