Commit f28a941e authored by astaxie's avatar astaxie

make golint happy and also make the config readable

parent 152127c2
......@@ -101,11 +101,11 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
m["AppConfigPath"] = AppConfigPath
m["StaticDir"] = StaticDir
m["StaticExtensionsToGzip"] = StaticExtensionsToGzip
m["HttpAddr"] = HttpAddr
m["HttpPort"] = HttpPort
m["HttpTLS"] = EnableHttpTLS
m["HttpCertFile"] = HttpCertFile
m["HttpKeyFile"] = HttpKeyFile
m["HTTPAddr"] = HTTPAddr
m["HTTPPort"] = HTTPPort
m["HTTPTLS"] = EnableHTTPTLS
m["HTTPCertFile"] = HTTPCertFile
m["HTTPKeyFile"] = HTTPKeyFile
m["RecoverPanic"] = RecoverPanic
m["AutoRender"] = AutoRender
m["ViewsPath"] = ViewsPath
......@@ -114,14 +114,14 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
m["SessionProvider"] = SessionProvider
m["SessionName"] = SessionName
m["SessionGCMaxLifetime"] = SessionGCMaxLifetime
m["SessionSavePath"] = SessionSavePath
m["SessionProviderConfig"] = SessionProviderConfig
m["SessionCookieLifeTime"] = SessionCookieLifeTime
m["UseFcgi"] = UseFcgi
m["EnabelFcgi"] = EnabelFcgi
m["MaxMemory"] = MaxMemory
m["EnableGzip"] = EnableGzip
m["DirectoryIndex"] = DirectoryIndex
m["HttpServerTimeOut"] = HttpServerTimeOut
m["ErrorsShow"] = ErrorsShow
m["HTTPServerTimeOut"] = HTTPServerTimeOut
m["EnableErrorsShow"] = EnableErrorsShow
m["XSRFKEY"] = XSRFKEY
m["EnableXSRF"] = EnableXSRF
m["XSRFExpire"] = XSRFExpire
......@@ -130,8 +130,8 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
m["TemplateRight"] = TemplateRight
m["BeegoServerName"] = BeegoServerName
m["EnableAdmin"] = EnableAdmin
m["AdminHttpAddr"] = AdminHttpAddr
m["AdminHttpPort"] = AdminHttpPort
m["AdminHTTPAddr"] = AdminHTTPAddr
m["AdminHTTPPort"] = AdminHTTPPort
tmpl := template.Must(template.New("dashboard").Parse(dashboardTpl))
tmpl = template.Must(tmpl.Parse(configTpl))
......@@ -451,10 +451,10 @@ func (admin *adminApp) Run() {
if len(toolbox.AdminTaskList) > 0 {
toolbox.StartTask()
}
addr := AdminHttpAddr
addr := AdminHTTPAddr
if AdminHttpPort != 0 {
addr = fmt.Sprintf("%s:%d", AdminHttpAddr, AdminHttpPort)
if AdminHTTPPort != 0 {
addr = fmt.Sprintf("%s:%d", AdminHTTPAddr, AdminHTTPPort)
}
for p, f := range admin.routers {
http.Handle(p, f)
......
......@@ -52,10 +52,10 @@ func NewApp() *App {
// Run beego application.
func (app *App) Run() {
addr := HttpAddr
addr := HTTPAddr
if HttpPort != 0 {
addr = fmt.Sprintf("%s:%d", HttpAddr, HttpPort)
if HTTPPort != 0 {
addr = fmt.Sprintf("%s:%d", HTTPAddr, HTTPPort)
}
var (
......@@ -64,8 +64,8 @@ func (app *App) Run() {
)
endRunning := make(chan bool, 1)
if UseFcgi {
if UseStdIo {
if EnabelFcgi {
if EnableStdIo {
err = fcgi.Serve(nil, app.Handlers) // standard I/O
if err == nil {
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)
}
} else {
if HttpPort == 0 {
if HTTPPort == 0 {
// remove the Socket file before start
if utils.FileExists(addr) {
os.Remove(addr)
......@@ -91,18 +91,18 @@ func (app *App) Run() {
if Graceful {
app.Server.Addr = addr
app.Server.Handler = app.Handlers
app.Server.ReadTimeout = time.Duration(HttpServerTimeOut) * time.Second
app.Server.WriteTimeout = time.Duration(HttpServerTimeOut) * time.Second
if EnableHttpTLS {
app.Server.ReadTimeout = time.Duration(HTTPServerTimeOut) * time.Second
app.Server.WriteTimeout = time.Duration(HTTPServerTimeOut) * time.Second
if EnableHTTPTLS {
go func() {
time.Sleep(20 * time.Microsecond)
if HttpsPort != 0 {
addr = fmt.Sprintf("%s:%d", HttpAddr, HttpsPort)
if HTTPSPort != 0 {
addr = fmt.Sprintf("%s:%d", HTTPAddr, HTTPSPort)
app.Server.Addr = addr
}
server := grace.NewServer(addr, app.Handlers)
server.Server = app.Server
err := server.ListenAndServeTLS(HttpCertFile, HttpKeyFile)
err := server.ListenAndServeTLS(HTTPCertFile, HTTPKeyFile)
if err != nil {
BeeLogger.Critical("ListenAndServeTLS: ", err, fmt.Sprintf("%d", os.Getpid()))
time.Sleep(100 * time.Microsecond)
......@@ -110,11 +110,11 @@ func (app *App) Run() {
}
}()
}
if EnableHttpListen {
if EnableHTTPListen {
go func() {
server := grace.NewServer(addr, app.Handlers)
server.Server = app.Server
if ListenTCP4 && HttpAddr == "" {
if ListenTCP4 && HTTPAddr == "" {
server.Network = "tcp4"
}
err := server.ListenAndServe()
......@@ -128,17 +128,17 @@ func (app *App) Run() {
} else {
app.Server.Addr = addr
app.Server.Handler = app.Handlers
app.Server.ReadTimeout = time.Duration(HttpServerTimeOut) * time.Second
app.Server.WriteTimeout = time.Duration(HttpServerTimeOut) * time.Second
app.Server.ReadTimeout = time.Duration(HTTPServerTimeOut) * time.Second
app.Server.WriteTimeout = time.Duration(HTTPServerTimeOut) * time.Second
if EnableHttpTLS {
if EnableHTTPTLS {
go func() {
time.Sleep(20 * time.Microsecond)
if HttpsPort != 0 {
app.Server.Addr = fmt.Sprintf("%s:%d", HttpAddr, HttpsPort)
if HTTPSPort != 0 {
app.Server.Addr = fmt.Sprintf("%s:%d", HTTPAddr, HTTPSPort)
}
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 {
BeeLogger.Critical("ListenAndServeTLS: ", err)
time.Sleep(100 * time.Microsecond)
......@@ -147,11 +147,11 @@ func (app *App) Run() {
}()
}
if EnableHttpListen {
if EnableHTTPListen {
go func() {
app.Server.Addr = 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)
if err != nil {
BeeLogger.Critical("ListenAndServe: ", err)
......
......@@ -48,10 +48,10 @@ func Run(params ...string) {
if len(params) > 0 && params[0] != "" {
strs := strings.Split(params[0], ":")
if len(strs) > 0 && strs[0] != "" {
HttpAddr = strs[0]
HTTPAddr = strs[0]
}
if len(strs) > 1 && strs[1] != "" {
HttpPort, _ = strconv.Atoi(strs[1])
HTTPPort, _ = strconv.Atoi(strs[1])
}
}
......
This diff is collapsed.
......@@ -65,8 +65,8 @@ func registerSession() error {
if sessionConfig == "" {
sessionConfig = `{"cookieName":"` + SessionName + `",` +
`"gclifetime":` + strconv.FormatInt(SessionGCMaxLifetime, 10) + `,` +
`"providerConfig":"` + filepath.ToSlash(SessionSavePath) + `",` +
`"secure":` + strconv.FormatBool(EnableHttpTLS) + `,` +
`"providerConfig":"` + filepath.ToSlash(SessionProviderConfig) + `",` +
`"secure":` + strconv.FormatBool(EnableHTTPTLS) + `,` +
`"enableSetCookie":` + strconv.FormatBool(SessionAutoSetCookie) + `,` +
`"domain":"` + SessionDomain + `",` +
`"cookieLifeTime":` + strconv.Itoa(SessionCookieLifeTime) + `}`
......
......@@ -617,7 +617,7 @@ func (p *ControllerRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request)
if ok, params := filterR.ValidRouter(urlPath); ok {
for k, v := range params {
if context.Input.Params == nil {
context.Input.Params = make(map[string]string)
context.Input.Params = make(map[string]string)
}
context.Input.Params[k] = v
}
......@@ -869,7 +869,7 @@ func (p *ControllerRegister) recoverPanic(context *beecontext.Context) {
if !RecoverPanic {
panic(err)
} else {
if ErrorsShow {
if EnableErrorsShow {
if _, ok := ErrorMaps[fmt.Sprint(err)]; ok {
exception(fmt.Sprint(err), context)
return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment