parent
0002ad0fb4
commit
53d9e8be69
2
client/cache/error_code.go
vendored
2
client/cache/error_code.go
vendored
@ -185,7 +185,7 @@ When you try to use SSDB cache, it failed. There are many cases:
|
|||||||
`)
|
`)
|
||||||
|
|
||||||
var SsdbBadResponse = berror.DefineCode(5002007, moduleName, "SsdbBadResponse", `
|
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.
|
Usually it indicates something wrong on server side.
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
|||||||
2
client/cache/file.go
vendored
2
client/cache/file.go
vendored
@ -122,7 +122,7 @@ func (fc *FileCache) Init() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// getCachedFilename returns an md5 encoded file name.
|
// getCacheFileName returns a md5 encoded file name.
|
||||||
func (fc *FileCache) getCacheFileName(key string) (string, error) {
|
func (fc *FileCache) getCacheFileName(key string) (string, error) {
|
||||||
m := md5.New()
|
m := md5.New()
|
||||||
_, _ = io.WriteString(m, key)
|
_, _ = io.WriteString(m, key)
|
||||||
|
|||||||
@ -2277,7 +2277,7 @@ func TestTxOrmRollbackUnlessCommit(t *testing.T) {
|
|||||||
o := NewOrm()
|
o := NewOrm()
|
||||||
var tag Tag
|
var tag Tag
|
||||||
|
|
||||||
// test not commited and call RollbackUnlessCommit
|
// test not committed and call RollbackUnlessCommit
|
||||||
to, err := o.Begin()
|
to, err := o.Begin()
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
tag.Name = "rollback unless commit"
|
tag.Name = "rollback unless commit"
|
||||||
|
|||||||
@ -317,19 +317,20 @@ func RouterWithOpts(rootpath string, c ControllerInterface, opts ...ControllerOp
|
|||||||
// Router adds a patterned controller handler to BeeApp.
|
// Router adds a patterned controller handler to BeeApp.
|
||||||
// it's an alias method of HttpServer.Router.
|
// it's an alias method of HttpServer.Router.
|
||||||
// usage:
|
// 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/:id([0-9]+)", &controllers.RController{})
|
||||||
// beego.Router("/api/list",&RestController{},"*:ListFood")
|
//
|
||||||
// beego.Router("/api/create",&RestController{},"post:CreateFood")
|
// custom rules
|
||||||
// beego.Router("/api/update",&RestController{},"put:UpdateFood")
|
// beego.Router("/api/list",&RestController{},"*:ListFood")
|
||||||
// beego.Router("/api/delete",&RestController{},"delete:DeleteFood")
|
// 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 {
|
func (app *HttpServer) Router(rootPath string, c ControllerInterface, mappingMethods ...string) *HttpServer {
|
||||||
return app.RouterWithOpts(rootPath, c, WithRouterMethods(c, mappingMethods...))
|
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.
|
// method type (e.g. "GET" or "POST") for selective removal.
|
||||||
//
|
//
|
||||||
// Usage (replace "GET" with "*" for all methods):
|
// 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 {
|
func (app *HttpServer) UnregisterFixedRoute(fixedRoute string, method string) *HttpServer {
|
||||||
subPaths := splitPath(fixedRoute)
|
subPaths := splitPath(fixedRoute)
|
||||||
if method == "" || method == "*" {
|
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
|
// 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{
|
//
|
||||||
// beego.Controller
|
// type BankAccount struct{
|
||||||
// }
|
// beego.Controller
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// register the function
|
// register the function
|
||||||
// func (b *BankAccount)Mapping(){
|
//
|
||||||
// b.Mapping("ShowAccount" , b.ShowAccount)
|
// func (b *BankAccount)Mapping(){
|
||||||
// b.Mapping("ModifyAccount", b.ModifyAccount)
|
// b.Mapping("ShowAccount" , b.ShowAccount)
|
||||||
// }
|
// b.Mapping("ModifyAccount", b.ModifyAccount)
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// //@router /account/:id [get]
|
// //@router /account/:id [get]
|
||||||
// func (b *BankAccount) ShowAccount(){
|
|
||||||
// //logic
|
|
||||||
// }
|
|
||||||
//
|
//
|
||||||
|
// func (b *BankAccount) ShowAccount(){
|
||||||
|
// //logic
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// //@router /account/:id [post]
|
// //@router /account/:id [post]
|
||||||
// func (b *BankAccount) ModifyAccount(){
|
//
|
||||||
// //logic
|
// func (b *BankAccount) ModifyAccount(){
|
||||||
// }
|
// //logic
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// the comments @router url methodlist
|
// the comments @router url methodlist
|
||||||
// url support all the function Router's pattern
|
// 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
|
// CtrlGet used to register router for CtrlGet method
|
||||||
// usage:
|
// 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 {
|
func (app *HttpServer) CtrlGet(rootpath string, f interface{}) *HttpServer {
|
||||||
app.Handlers.CtrlGet(rootpath, f)
|
app.Handlers.CtrlGet(rootpath, f)
|
||||||
return app
|
return app
|
||||||
@ -528,14 +534,15 @@ func CtrlPost(rootpath string, f interface{}) {
|
|||||||
|
|
||||||
// CtrlPost used to register router for CtrlPost method
|
// CtrlPost used to register router for CtrlPost method
|
||||||
// usage:
|
// 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 {
|
func (app *HttpServer) CtrlPost(rootpath string, f interface{}) *HttpServer {
|
||||||
app.Handlers.CtrlPost(rootpath, f)
|
app.Handlers.CtrlPost(rootpath, f)
|
||||||
return app
|
return app
|
||||||
@ -548,14 +555,15 @@ func CtrlHead(rootpath string, f interface{}) {
|
|||||||
|
|
||||||
// CtrlHead used to register router for CtrlHead method
|
// CtrlHead used to register router for CtrlHead method
|
||||||
// usage:
|
// 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 {
|
func (app *HttpServer) CtrlHead(rootpath string, f interface{}) *HttpServer {
|
||||||
app.Handlers.CtrlHead(rootpath, f)
|
app.Handlers.CtrlHead(rootpath, f)
|
||||||
return app
|
return app
|
||||||
@ -568,14 +576,15 @@ func CtrlPut(rootpath string, f interface{}) {
|
|||||||
|
|
||||||
// CtrlPut used to register router for CtrlPut method
|
// CtrlPut used to register router for CtrlPut method
|
||||||
// usage:
|
// 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 {
|
func (app *HttpServer) CtrlPut(rootpath string, f interface{}) *HttpServer {
|
||||||
app.Handlers.CtrlPut(rootpath, f)
|
app.Handlers.CtrlPut(rootpath, f)
|
||||||
return app
|
return app
|
||||||
@ -588,14 +597,15 @@ func CtrlPatch(rootpath string, f interface{}) {
|
|||||||
|
|
||||||
// CtrlPatch used to register router for CtrlPatch method
|
// CtrlPatch used to register router for CtrlPatch method
|
||||||
// usage:
|
// 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 {
|
func (app *HttpServer) CtrlPatch(rootpath string, f interface{}) *HttpServer {
|
||||||
app.Handlers.CtrlPatch(rootpath, f)
|
app.Handlers.CtrlPatch(rootpath, f)
|
||||||
return app
|
return app
|
||||||
@ -608,14 +618,15 @@ func CtrlDelete(rootpath string, f interface{}) {
|
|||||||
|
|
||||||
// CtrlDelete used to register router for CtrlDelete method
|
// CtrlDelete used to register router for CtrlDelete method
|
||||||
// usage:
|
// 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 {
|
func (app *HttpServer) CtrlDelete(rootpath string, f interface{}) *HttpServer {
|
||||||
app.Handlers.CtrlDelete(rootpath, f)
|
app.Handlers.CtrlDelete(rootpath, f)
|
||||||
return app
|
return app
|
||||||
@ -628,14 +639,15 @@ func CtrlOptions(rootpath string, f interface{}) {
|
|||||||
|
|
||||||
// CtrlOptions used to register router for CtrlOptions method
|
// CtrlOptions used to register router for CtrlOptions method
|
||||||
// usage:
|
// 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 {
|
func (app *HttpServer) CtrlOptions(rootpath string, f interface{}) *HttpServer {
|
||||||
app.Handlers.CtrlOptions(rootpath, f)
|
app.Handlers.CtrlOptions(rootpath, f)
|
||||||
return app
|
return app
|
||||||
@ -648,14 +660,15 @@ func CtrlAny(rootpath string, f interface{}) {
|
|||||||
|
|
||||||
// CtrlAny used to register router for CtrlAny method
|
// CtrlAny used to register router for CtrlAny method
|
||||||
// usage:
|
// 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 {
|
func (app *HttpServer) CtrlAny(rootpath string, f interface{}) *HttpServer {
|
||||||
app.Handlers.CtrlAny(rootpath, f)
|
app.Handlers.CtrlAny(rootpath, f)
|
||||||
return app
|
return app
|
||||||
@ -668,9 +681,10 @@ func Get(rootpath string, f HandleFunc) *HttpServer {
|
|||||||
|
|
||||||
// Get used to register router for Get method
|
// Get used to register router for Get method
|
||||||
// usage:
|
// 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 {
|
func (app *HttpServer) Get(rootpath string, f HandleFunc) *HttpServer {
|
||||||
app.Handlers.Get(rootpath, f)
|
app.Handlers.Get(rootpath, f)
|
||||||
return app
|
return app
|
||||||
@ -683,9 +697,10 @@ func Post(rootpath string, f HandleFunc) *HttpServer {
|
|||||||
|
|
||||||
// Post used to register router for Post method
|
// Post used to register router for Post method
|
||||||
// usage:
|
// 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 {
|
func (app *HttpServer) Post(rootpath string, f HandleFunc) *HttpServer {
|
||||||
app.Handlers.Post(rootpath, f)
|
app.Handlers.Post(rootpath, f)
|
||||||
return app
|
return app
|
||||||
@ -698,9 +713,10 @@ func Delete(rootpath string, f HandleFunc) *HttpServer {
|
|||||||
|
|
||||||
// Delete used to register router for Delete method
|
// Delete used to register router for Delete method
|
||||||
// usage:
|
// 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 {
|
func (app *HttpServer) Delete(rootpath string, f HandleFunc) *HttpServer {
|
||||||
app.Handlers.Delete(rootpath, f)
|
app.Handlers.Delete(rootpath, f)
|
||||||
return app
|
return app
|
||||||
@ -713,9 +729,10 @@ func Put(rootpath string, f HandleFunc) *HttpServer {
|
|||||||
|
|
||||||
// Put used to register router for Put method
|
// Put used to register router for Put method
|
||||||
// usage:
|
// 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 {
|
func (app *HttpServer) Put(rootpath string, f HandleFunc) *HttpServer {
|
||||||
app.Handlers.Put(rootpath, f)
|
app.Handlers.Put(rootpath, f)
|
||||||
return app
|
return app
|
||||||
@ -728,9 +745,10 @@ func Head(rootpath string, f HandleFunc) *HttpServer {
|
|||||||
|
|
||||||
// Head used to register router for Head method
|
// Head used to register router for Head method
|
||||||
// usage:
|
// 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 {
|
func (app *HttpServer) Head(rootpath string, f HandleFunc) *HttpServer {
|
||||||
app.Handlers.Head(rootpath, f)
|
app.Handlers.Head(rootpath, f)
|
||||||
return app
|
return app
|
||||||
@ -744,9 +762,10 @@ func Options(rootpath string, f HandleFunc) *HttpServer {
|
|||||||
|
|
||||||
// Options used to register router for Options method
|
// Options used to register router for Options method
|
||||||
// usage:
|
// 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 {
|
func (app *HttpServer) Options(rootpath string, f HandleFunc) *HttpServer {
|
||||||
app.Handlers.Options(rootpath, f)
|
app.Handlers.Options(rootpath, f)
|
||||||
return app
|
return app
|
||||||
@ -759,9 +778,10 @@ func Patch(rootpath string, f HandleFunc) *HttpServer {
|
|||||||
|
|
||||||
// Patch used to register router for Patch method
|
// Patch used to register router for Patch method
|
||||||
// usage:
|
// 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 {
|
func (app *HttpServer) Patch(rootpath string, f HandleFunc) *HttpServer {
|
||||||
app.Handlers.Patch(rootpath, f)
|
app.Handlers.Patch(rootpath, f)
|
||||||
return app
|
return app
|
||||||
@ -774,9 +794,10 @@ func Any(rootpath string, f HandleFunc) *HttpServer {
|
|||||||
|
|
||||||
// Any used to register router for all methods
|
// Any used to register router for all methods
|
||||||
// usage:
|
// 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 {
|
func (app *HttpServer) Any(rootpath string, f HandleFunc) *HttpServer {
|
||||||
app.Handlers.Any(rootpath, f)
|
app.Handlers.Any(rootpath, f)
|
||||||
return app
|
return app
|
||||||
@ -789,15 +810,16 @@ func Handler(rootpath string, h http.Handler, options ...interface{}) *HttpServe
|
|||||||
|
|
||||||
// Handler used to register a Handler router
|
// Handler used to register a Handler router
|
||||||
// usage:
|
// 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 {
|
func (app *HttpServer) Handler(rootpath string, h http.Handler, options ...interface{}) *HttpServer {
|
||||||
app.Handlers.Handler(rootpath, h, options...)
|
app.Handlers.Handler(rootpath, h, options...)
|
||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
// InserFilter see HttpServer.InsertFilter
|
// InsertFilter see HttpServer.InsertFilter
|
||||||
func InsertFilter(pattern string, pos int, filter FilterFunc, opts ...FilterOpt) *HttpServer {
|
func InsertFilter(pattern string, pos int, filter FilterFunc, opts ...FilterOpt) *HttpServer {
|
||||||
return BeeApp.InsertFilter(pattern, pos, filter, opts...)
|
return BeeApp.InsertFilter(pattern, pos, filter, opts...)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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 {
|
func CfgSessionIdLength(length int64) ManagerConfigOpt {
|
||||||
return func(config *ManagerConfig) {
|
return func(config *ManagerConfig) {
|
||||||
config.SessionIDLength = length
|
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 {
|
func CfgCookieLifeTime(lifeTime int) ManagerConfigOpt {
|
||||||
return func(config *ManagerConfig) {
|
return func(config *ManagerConfig) {
|
||||||
config.CookieLifeTime = lifeTime
|
config.CookieLifeTime = lifeTime
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user