1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-26 03:01:28 +00:00

make golint happy

This commit is contained in:
astaxie 2015-09-07 21:38:53 +08:00
parent 919675e793
commit 152127c2af
4 changed files with 20 additions and 19 deletions

View File

@ -314,14 +314,14 @@ func profIndex(rw http.ResponseWriter, r *http.Request) {
data["Content"] = result.String() data["Content"] = result.String()
if format == "json" && command == "gc summary" { if format == "json" && command == "gc summary" {
dataJson, err := json.Marshal(data) dataJSON, err := json.Marshal(data)
if err != nil { if err != nil {
http.Error(rw, err.Error(), http.StatusInternalServerError) http.Error(rw, err.Error(), http.StatusInternalServerError)
return return
} }
rw.Header().Set("Content-Type", "application/json") rw.Header().Set("Content-Type", "application/json")
rw.Write(dataJson) rw.Write(dataJSON)
return return
} }

21
app.go
View File

@ -28,6 +28,7 @@ import (
) )
var ( var (
// BeeApp is an application instance
BeeApp *App BeeApp *App
) )
@ -202,7 +203,7 @@ func Router(rootpath string, c ControllerInterface, mappingMethods ...string) *A
return BeeApp return BeeApp
} }
// Router add list from // Include will generate router file in the router/xxx.go from the controller's comments
// usage: // usage:
// beego.Include(&BankAccount{}, &OrderController{},&RefundController{},&ReceiptController{}) // beego.Include(&BankAccount{}, &OrderController{},&RefundController{},&ReceiptController{})
// type BankAccount struct{ // type BankAccount struct{
@ -261,7 +262,7 @@ func AutoPrefix(prefix string, c ControllerInterface) *App {
return BeeApp return BeeApp
} }
// register router for Get method // Get used to register router for Get method
// usage: // usage:
// beego.Get("/", func(ctx *context.Context){ // beego.Get("/", func(ctx *context.Context){
// ctx.Output.Body("hello world") // ctx.Output.Body("hello world")
@ -271,7 +272,7 @@ func Get(rootpath string, f FilterFunc) *App {
return BeeApp return BeeApp
} }
// register router for Post method // Post used to register router for Post method
// usage: // usage:
// beego.Post("/api", func(ctx *context.Context){ // beego.Post("/api", func(ctx *context.Context){
// ctx.Output.Body("hello world") // ctx.Output.Body("hello world")
@ -281,7 +282,7 @@ func Post(rootpath string, f FilterFunc) *App {
return BeeApp return BeeApp
} }
// register router for Delete method // Delete used to register router for Delete method
// usage: // usage:
// beego.Delete("/api", func(ctx *context.Context){ // beego.Delete("/api", func(ctx *context.Context){
// ctx.Output.Body("hello world") // ctx.Output.Body("hello world")
@ -291,7 +292,7 @@ func Delete(rootpath string, f FilterFunc) *App {
return BeeApp return BeeApp
} }
// register router for Put method // Put used to register router for Put method
// usage: // usage:
// beego.Put("/api", func(ctx *context.Context){ // beego.Put("/api", func(ctx *context.Context){
// ctx.Output.Body("hello world") // ctx.Output.Body("hello world")
@ -301,7 +302,7 @@ func Put(rootpath string, f FilterFunc) *App {
return BeeApp return BeeApp
} }
// register router for Head method // Head used to register router for Head method
// usage: // usage:
// beego.Head("/api", func(ctx *context.Context){ // beego.Head("/api", func(ctx *context.Context){
// ctx.Output.Body("hello world") // ctx.Output.Body("hello world")
@ -311,7 +312,7 @@ func Head(rootpath string, f FilterFunc) *App {
return BeeApp return BeeApp
} }
// register router for Options method // Options used to register router for Options method
// usage: // usage:
// beego.Options("/api", func(ctx *context.Context){ // beego.Options("/api", func(ctx *context.Context){
// ctx.Output.Body("hello world") // ctx.Output.Body("hello world")
@ -321,7 +322,7 @@ func Options(rootpath string, f FilterFunc) *App {
return BeeApp return BeeApp
} }
// register router for Patch method // Patch used to register router for Patch method
// usage: // usage:
// beego.Patch("/api", func(ctx *context.Context){ // beego.Patch("/api", func(ctx *context.Context){
// ctx.Output.Body("hello world") // ctx.Output.Body("hello world")
@ -331,7 +332,7 @@ func Patch(rootpath string, f FilterFunc) *App {
return BeeApp return BeeApp
} }
// register router for all method // Any used to register router for all methods
// usage: // usage:
// beego.Any("/api", func(ctx *context.Context){ // beego.Any("/api", func(ctx *context.Context){
// ctx.Output.Body("hello world") // ctx.Output.Body("hello world")
@ -341,7 +342,7 @@ func Any(rootpath string, f FilterFunc) *App {
return BeeApp return BeeApp
} }
// register router for own Handler // Handler used to register a Handler router
// usage: // usage:
// beego.Handler("/api", func(ctx *context.Context){ // beego.Handler("/api", func(ctx *context.Context){
// ctx.Output.Body("hello world") // ctx.Output.Body("hello world")

View File

@ -31,7 +31,8 @@ var (
hooks = make([]hookfunc, 0) //hook function slice to store the hookfunc hooks = make([]hookfunc, 0) //hook function slice to store the hookfunc
) )
// The hookfunc will run in beego.Run() // AddAPPStartHook is used to register the hookfunc
// The hookfuncs will run in beego.Run()
// such as sessionInit, middlerware start, buildtemplate, admin start // such as sessionInit, middlerware start, buildtemplate, admin start
func AddAPPStartHook(hf hookfunc) { func AddAPPStartHook(hf hookfunc) {
hooks = append(hooks, hf) hooks = append(hooks, hf)
@ -42,7 +43,7 @@ func AddAPPStartHook(hf hookfunc) {
// beego.Run(":8089") // beego.Run(":8089")
// beego.Run("127.0.0.1:8089") // beego.Run("127.0.0.1:8089")
func Run(params ...string) { func Run(params ...string) {
initBeforeHttpRun() initBeforeHTTPRun()
if len(params) > 0 && params[0] != "" { if len(params) > 0 && params[0] != "" {
strs := strings.Split(params[0], ":") strs := strings.Split(params[0], ":")
@ -57,7 +58,7 @@ func Run(params ...string) {
BeeApp.Run() BeeApp.Run()
} }
func initBeforeHttpRun() { func initBeforeHTTPRun() {
// if AppConfigPath not In the conf/app.conf reParse config // if AppConfigPath not In the conf/app.conf reParse config
if AppConfigPath != filepath.Join(AppPath, "conf", "app.conf") { if AppConfigPath != filepath.Join(AppPath, "conf", "app.conf") {
err := ParseConfig() err := ParseConfig()
@ -82,7 +83,7 @@ func initBeforeHttpRun() {
} }
} }
// this function is for test package init // TestBeegoInit is for test package init
func TestBeegoInit(apppath string) { func TestBeegoInit(apppath string) {
AppPath = apppath AppPath = apppath
os.Setenv("BEEGO_RUNMODE", "test") os.Setenv("BEEGO_RUNMODE", "test")
@ -93,5 +94,5 @@ func TestBeegoInit(apppath string) {
Info(err) Info(err)
} }
os.Chdir(AppPath) os.Chdir(AppPath)
initBeforeHttpRun() initBeforeHTTPRun()
} }

View File

@ -71,8 +71,7 @@ func registerSession() error {
`"domain":"` + SessionDomain + `",` + `"domain":"` + SessionDomain + `",` +
`"cookieLifeTime":` + strconv.Itoa(SessionCookieLifeTime) + `}` `"cookieLifeTime":` + strconv.Itoa(SessionCookieLifeTime) + `}`
} }
GlobalSessions, err = session.NewManager(SessionProvider, GlobalSessions, err = session.NewManager(SessionProvider, sessionConfig)
sessionConfig)
if err != nil { if err != nil {
return err return err
} }