diff --git a/client/cache/error_code.go b/client/cache/error_code.go index 39549a55..74e387a1 100644 --- a/client/cache/error_code.go +++ b/client/cache/error_code.go @@ -185,7 +185,7 @@ When you try to use SSDB cache, it failed. There are many cases: `) var SsdbBadResponse = berror.DefineCode(5002007, moduleName, "SsdbBadResponse", ` -The reponse from SSDB server is invalid. +The response from SSDB server is invalid. Usually it indicates something wrong on server side. `) diff --git a/client/cache/file.go b/client/cache/file.go index ae2bc7cf..172c568e 100644 --- a/client/cache/file.go +++ b/client/cache/file.go @@ -122,7 +122,7 @@ func (fc *FileCache) Init() error { return nil } -// getCachedFilename returns an md5 encoded file name. +// getCacheFileName returns a md5 encoded file name. func (fc *FileCache) getCacheFileName(key string) (string, error) { m := md5.New() _, _ = io.WriteString(m, key) diff --git a/client/orm/orm_test.go b/client/orm/orm_test.go index 55d9ba18..4fbd3a20 100644 --- a/client/orm/orm_test.go +++ b/client/orm/orm_test.go @@ -2277,7 +2277,7 @@ func TestTxOrmRollbackUnlessCommit(t *testing.T) { o := NewOrm() var tag Tag - // test not commited and call RollbackUnlessCommit + // test not committed and call RollbackUnlessCommit to, err := o.Begin() assert.Nil(t, err) tag.Name = "rollback unless commit" diff --git a/server/web/server.go b/server/web/server.go index fe4c6164..a1a56230 100644 --- a/server/web/server.go +++ b/server/web/server.go @@ -317,19 +317,20 @@ func RouterWithOpts(rootpath string, c ControllerInterface, opts ...ControllerOp // Router adds a patterned controller handler to BeeApp. // it's an alias method of HttpServer.Router. // usage: -// simple router -// beego.Router("/admin", &admin.UserController{}) -// beego.Router("/admin/index", &admin.ArticleController{}) // -// regex router +// simple router +// beego.Router("/admin", &admin.UserController{}) +// beego.Router("/admin/index", &admin.ArticleController{}) // -// beego.Router("/api/:id([0-9]+)", &controllers.RController{}) +// regex router // -// custom rules -// beego.Router("/api/list",&RestController{},"*:ListFood") -// beego.Router("/api/create",&RestController{},"post:CreateFood") -// beego.Router("/api/update",&RestController{},"put:UpdateFood") -// beego.Router("/api/delete",&RestController{},"delete:DeleteFood") +// beego.Router("/api/:id([0-9]+)", &controllers.RController{}) +// +// custom rules +// beego.Router("/api/list",&RestController{},"*:ListFood") +// beego.Router("/api/create",&RestController{},"post:CreateFood") +// beego.Router("/api/update",&RestController{},"put:UpdateFood") +// beego.Router("/api/delete",&RestController{},"delete:DeleteFood") func (app *HttpServer) Router(rootPath string, c ControllerInterface, mappingMethods ...string) *HttpServer { return app.RouterWithOpts(rootPath, c, WithRouterMethods(c, mappingMethods...)) } @@ -351,8 +352,9 @@ func UnregisterFixedRoute(fixedRoute string, method string) *HttpServer { // method type (e.g. "GET" or "POST") for selective removal. // // Usage (replace "GET" with "*" for all methods): -// beego.UnregisterFixedRoute("/yourpreviouspath", "GET") -// beego.Router("/yourpreviouspath", yourControllerAddress, "get:GetNewPage") +// +// beego.UnregisterFixedRoute("/yourpreviouspath", "GET") +// beego.Router("/yourpreviouspath", yourControllerAddress, "get:GetNewPage") func (app *HttpServer) UnregisterFixedRoute(fixedRoute string, method string) *HttpServer { subPaths := splitPath(fixedRoute) if method == "" || method == "*" { @@ -430,26 +432,29 @@ func Include(cList ...ControllerInterface) *HttpServer { // Include will generate router file in the router/xxx.go from the controller's comments // usage: // beego.Include(&BankAccount{}, &OrderController{},&RefundController{},&ReceiptController{}) -// type BankAccount struct{ -// beego.Controller -// } +// +// type BankAccount struct{ +// beego.Controller +// } // // register the function -// func (b *BankAccount)Mapping(){ -// b.Mapping("ShowAccount" , b.ShowAccount) -// b.Mapping("ModifyAccount", b.ModifyAccount) -// } +// +// func (b *BankAccount)Mapping(){ +// b.Mapping("ShowAccount" , b.ShowAccount) +// b.Mapping("ModifyAccount", b.ModifyAccount) +// } // // //@router /account/:id [get] -// func (b *BankAccount) ShowAccount(){ -// //logic -// } // +// func (b *BankAccount) ShowAccount(){ +// //logic +// } // // //@router /account/:id [post] -// func (b *BankAccount) ModifyAccount(){ -// //logic -// } +// +// func (b *BankAccount) ModifyAccount(){ +// //logic +// } // // the comments @router url methodlist // url support all the function Router's pattern @@ -508,14 +513,15 @@ func CtrlGet(rootpath string, f interface{}) { // CtrlGet used to register router for CtrlGet method // usage: -// type MyController struct { -// web.Controller -// } -// func (m MyController) Ping() { -// m.Ctx.Output.Body([]byte("hello world")) -// } // -// CtrlGet("/api/:id", MyController.Ping) +// type MyController struct { +// web.Controller +// } +// func (m MyController) Ping() { +// m.Ctx.Output.Body([]byte("hello world")) +// } +// +// CtrlGet("/api/:id", MyController.Ping) func (app *HttpServer) CtrlGet(rootpath string, f interface{}) *HttpServer { app.Handlers.CtrlGet(rootpath, f) return app @@ -528,14 +534,15 @@ func CtrlPost(rootpath string, f interface{}) { // CtrlPost used to register router for CtrlPost method // usage: -// type MyController struct { -// web.Controller -// } -// func (m MyController) Ping() { -// m.Ctx.Output.Body([]byte("hello world")) -// } // -// CtrlPost("/api/:id", MyController.Ping) +// type MyController struct { +// web.Controller +// } +// func (m MyController) Ping() { +// m.Ctx.Output.Body([]byte("hello world")) +// } +// +// CtrlPost("/api/:id", MyController.Ping) func (app *HttpServer) CtrlPost(rootpath string, f interface{}) *HttpServer { app.Handlers.CtrlPost(rootpath, f) return app @@ -548,14 +555,15 @@ func CtrlHead(rootpath string, f interface{}) { // CtrlHead used to register router for CtrlHead method // usage: -// type MyController struct { -// web.Controller -// } -// func (m MyController) Ping() { -// m.Ctx.Output.Body([]byte("hello world")) -// } // -// CtrlHead("/api/:id", MyController.Ping) +// type MyController struct { +// web.Controller +// } +// func (m MyController) Ping() { +// m.Ctx.Output.Body([]byte("hello world")) +// } +// +// CtrlHead("/api/:id", MyController.Ping) func (app *HttpServer) CtrlHead(rootpath string, f interface{}) *HttpServer { app.Handlers.CtrlHead(rootpath, f) return app @@ -568,14 +576,15 @@ func CtrlPut(rootpath string, f interface{}) { // CtrlPut used to register router for CtrlPut method // usage: -// type MyController struct { -// web.Controller -// } -// func (m MyController) Ping() { -// m.Ctx.Output.Body([]byte("hello world")) -// } // -// CtrlPut("/api/:id", MyController.Ping) +// type MyController struct { +// web.Controller +// } +// func (m MyController) Ping() { +// m.Ctx.Output.Body([]byte("hello world")) +// } +// +// CtrlPut("/api/:id", MyController.Ping) func (app *HttpServer) CtrlPut(rootpath string, f interface{}) *HttpServer { app.Handlers.CtrlPut(rootpath, f) return app @@ -588,14 +597,15 @@ func CtrlPatch(rootpath string, f interface{}) { // CtrlPatch used to register router for CtrlPatch method // usage: -// type MyController struct { -// web.Controller -// } -// func (m MyController) Ping() { -// m.Ctx.Output.Body([]byte("hello world")) -// } // -// CtrlPatch("/api/:id", MyController.Ping) +// type MyController struct { +// web.Controller +// } +// func (m MyController) Ping() { +// m.Ctx.Output.Body([]byte("hello world")) +// } +// +// CtrlPatch("/api/:id", MyController.Ping) func (app *HttpServer) CtrlPatch(rootpath string, f interface{}) *HttpServer { app.Handlers.CtrlPatch(rootpath, f) return app @@ -608,14 +618,15 @@ func CtrlDelete(rootpath string, f interface{}) { // CtrlDelete used to register router for CtrlDelete method // usage: -// type MyController struct { -// web.Controller -// } -// func (m MyController) Ping() { -// m.Ctx.Output.Body([]byte("hello world")) -// } // -// CtrlDelete("/api/:id", MyController.Ping) +// type MyController struct { +// web.Controller +// } +// func (m MyController) Ping() { +// m.Ctx.Output.Body([]byte("hello world")) +// } +// +// CtrlDelete("/api/:id", MyController.Ping) func (app *HttpServer) CtrlDelete(rootpath string, f interface{}) *HttpServer { app.Handlers.CtrlDelete(rootpath, f) return app @@ -628,14 +639,15 @@ func CtrlOptions(rootpath string, f interface{}) { // CtrlOptions used to register router for CtrlOptions method // usage: -// type MyController struct { -// web.Controller -// } -// func (m MyController) Ping() { -// m.Ctx.Output.Body([]byte("hello world")) -// } // -// CtrlOptions("/api/:id", MyController.Ping) +// type MyController struct { +// web.Controller +// } +// func (m MyController) Ping() { +// m.Ctx.Output.Body([]byte("hello world")) +// } +// +// CtrlOptions("/api/:id", MyController.Ping) func (app *HttpServer) CtrlOptions(rootpath string, f interface{}) *HttpServer { app.Handlers.CtrlOptions(rootpath, f) return app @@ -648,14 +660,15 @@ func CtrlAny(rootpath string, f interface{}) { // CtrlAny used to register router for CtrlAny method // usage: -// type MyController struct { -// web.Controller -// } -// func (m MyController) Ping() { -// m.Ctx.Output.Body([]byte("hello world")) -// } // -// CtrlAny("/api/:id", MyController.Ping) +// type MyController struct { +// web.Controller +// } +// func (m MyController) Ping() { +// m.Ctx.Output.Body([]byte("hello world")) +// } +// +// CtrlAny("/api/:id", MyController.Ping) func (app *HttpServer) CtrlAny(rootpath string, f interface{}) *HttpServer { app.Handlers.CtrlAny(rootpath, f) return app @@ -668,9 +681,10 @@ func Get(rootpath string, f HandleFunc) *HttpServer { // Get used to register router for Get method // usage: -// beego.Get("/", func(ctx *context.Context){ -// ctx.Output.Body("hello world") -// }) +// +// beego.Get("/", func(ctx *context.Context){ +// ctx.Output.Body("hello world") +// }) func (app *HttpServer) Get(rootpath string, f HandleFunc) *HttpServer { app.Handlers.Get(rootpath, f) return app @@ -683,9 +697,10 @@ func Post(rootpath string, f HandleFunc) *HttpServer { // Post used to register router for Post method // usage: -// beego.Post("/api", func(ctx *context.Context){ -// ctx.Output.Body("hello world") -// }) +// +// beego.Post("/api", func(ctx *context.Context){ +// ctx.Output.Body("hello world") +// }) func (app *HttpServer) Post(rootpath string, f HandleFunc) *HttpServer { app.Handlers.Post(rootpath, f) return app @@ -698,9 +713,10 @@ func Delete(rootpath string, f HandleFunc) *HttpServer { // Delete used to register router for Delete method // usage: -// beego.Delete("/api", func(ctx *context.Context){ -// ctx.Output.Body("hello world") -// }) +// +// beego.Delete("/api", func(ctx *context.Context){ +// ctx.Output.Body("hello world") +// }) func (app *HttpServer) Delete(rootpath string, f HandleFunc) *HttpServer { app.Handlers.Delete(rootpath, f) return app @@ -713,9 +729,10 @@ func Put(rootpath string, f HandleFunc) *HttpServer { // Put used to register router for Put method // usage: -// beego.Put("/api", func(ctx *context.Context){ -// ctx.Output.Body("hello world") -// }) +// +// beego.Put("/api", func(ctx *context.Context){ +// ctx.Output.Body("hello world") +// }) func (app *HttpServer) Put(rootpath string, f HandleFunc) *HttpServer { app.Handlers.Put(rootpath, f) return app @@ -728,9 +745,10 @@ func Head(rootpath string, f HandleFunc) *HttpServer { // Head used to register router for Head method // usage: -// beego.Head("/api", func(ctx *context.Context){ -// ctx.Output.Body("hello world") -// }) +// +// beego.Head("/api", func(ctx *context.Context){ +// ctx.Output.Body("hello world") +// }) func (app *HttpServer) Head(rootpath string, f HandleFunc) *HttpServer { app.Handlers.Head(rootpath, f) return app @@ -744,9 +762,10 @@ func Options(rootpath string, f HandleFunc) *HttpServer { // Options used to register router for Options method // usage: -// beego.Options("/api", func(ctx *context.Context){ -// ctx.Output.Body("hello world") -// }) +// +// beego.Options("/api", func(ctx *context.Context){ +// ctx.Output.Body("hello world") +// }) func (app *HttpServer) Options(rootpath string, f HandleFunc) *HttpServer { app.Handlers.Options(rootpath, f) return app @@ -759,9 +778,10 @@ func Patch(rootpath string, f HandleFunc) *HttpServer { // Patch used to register router for Patch method // usage: -// beego.Patch("/api", func(ctx *context.Context){ -// ctx.Output.Body("hello world") -// }) +// +// beego.Patch("/api", func(ctx *context.Context){ +// ctx.Output.Body("hello world") +// }) func (app *HttpServer) Patch(rootpath string, f HandleFunc) *HttpServer { app.Handlers.Patch(rootpath, f) return app @@ -774,9 +794,10 @@ func Any(rootpath string, f HandleFunc) *HttpServer { // Any used to register router for all methods // usage: -// beego.Any("/api", func(ctx *context.Context){ -// ctx.Output.Body("hello world") -// }) +// +// beego.Any("/api", func(ctx *context.Context){ +// ctx.Output.Body("hello world") +// }) func (app *HttpServer) Any(rootpath string, f HandleFunc) *HttpServer { app.Handlers.Any(rootpath, f) return app @@ -789,15 +810,16 @@ func Handler(rootpath string, h http.Handler, options ...interface{}) *HttpServe // Handler used to register a Handler router // usage: -// beego.Handler("/api", http.HandlerFunc(func (w http.ResponseWriter, r *http.Request) { -// fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path)) -// })) +// +// beego.Handler("/api", http.HandlerFunc(func (w http.ResponseWriter, r *http.Request) { +// fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path)) +// })) func (app *HttpServer) Handler(rootpath string, h http.Handler, options ...interface{}) *HttpServer { app.Handlers.Handler(rootpath, h, options...) return app } -// InserFilter see HttpServer.InsertFilter +// InsertFilter see HttpServer.InsertFilter func InsertFilter(pattern string, pos int, filter FilterFunc, opts ...FilterOpt) *HttpServer { return BeeApp.InsertFilter(pattern, pos, filter, opts...) } diff --git a/server/web/session/session_config.go b/server/web/session/session_config.go index d9514003..65d36dde 100644 --- a/server/web/session/session_config.go +++ b/server/web/session/session_config.go @@ -44,7 +44,7 @@ func CfgCookieName(cookieName string) ManagerConfigOpt { } } -// CfgCookieName set len of session id +// CfgSessionIdLength set len of session id func CfgSessionIdLength(length int64) ManagerConfigOpt { return func(config *ManagerConfig) { config.SessionIDLength = length @@ -79,7 +79,7 @@ func CfgMaxLifeTime(lifeTime int64) ManagerConfigOpt { } } -// CfgGcLifeTime set session lift time +// CfgCookieLifeTime set cookie lift time func CfgCookieLifeTime(lifeTime int) ManagerConfigOpt { return func(config *ManagerConfig) { config.CookieLifeTime = lifeTime