From e8b29c9fd18e97a56821e7f80464f80965dc6e71 Mon Sep 17 00:00:00 2001 From: JessonChan Date: Wed, 27 Mar 2019 13:34:46 +0800 Subject: [PATCH 01/13] handle trace request --- controller.go | 63 +++++++++++++++++++++++++++++++++++++-------------- router.go | 2 ++ 2 files changed, 48 insertions(+), 17 deletions(-) diff --git a/controller.go b/controller.go index 9c605760..e6ecd12e 100644 --- a/controller.go +++ b/controller.go @@ -27,6 +27,8 @@ import ( "strconv" "strings" + "fmt" + "github.com/astaxie/beego/context" "github.com/astaxie/beego/context/param" "github.com/astaxie/beego/session" @@ -78,24 +80,30 @@ type ControllerComments struct { // ControllerCommentsSlice implements the sort interface type ControllerCommentsSlice []ControllerComments -func (p ControllerCommentsSlice) Len() int { return len(p) } -func (p ControllerCommentsSlice) Less(i, j int) bool { return p[i].Router < p[j].Router } -func (p ControllerCommentsSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } +func (p ControllerCommentsSlice) Len() int { + return len(p) +} +func (p ControllerCommentsSlice) Less(i, j int) bool { + return p[i].Router < p[j].Router +} +func (p ControllerCommentsSlice) Swap(i, j int) { + p[i], p[j] = p[j], p[i] +} // Controller defines some basic http request handler operations, such as // http context, template and view, session and xsrf. type Controller struct { - // context data - Ctx *context.Context - Data map[interface{}]interface{} + // context data + Ctx *context.Context + Data map[interface{}]interface{} - // route controller info + // route controller info controllerName string actionName string methodMapping map[string]func() //method:routertree AppController interface{} - // template data + // template data TplName string ViewPath string Layout string @@ -104,13 +112,13 @@ type Controller struct { TplExt string EnableRender bool - // xsrf data - _xsrfToken string - XSRFExpire int - EnableXSRF bool + // xsrf data + _xsrfToken string + XSRFExpire int + EnableXSRF bool - // session - CruSession session.Store + // session + CruSession session.Store } // ControllerInterface is an interface to uniform all controller handler. @@ -124,6 +132,7 @@ type ControllerInterface interface { Head() Patch() Options() + Trace() Finish() Render() error XSRFToken() string @@ -188,6 +197,26 @@ func (c *Controller) Options() { http.Error(c.Ctx.ResponseWriter, "Method Not Allowed", http.StatusMethodNotAllowed) } +// Trace adds a request function to handle Trace request. +// https://tools.ietf.org/html/rfc7231#section-4.3.8 +// The TRACE method requests a remote, application-level loop-back of +// the request message. The final recipient of the request SHOULD +// reflect the message received, excluding some fields described below, +// back to the client as the message body of a 200 (OK) response with a +// Content-Type of "message/http" (Section 8.3.1 of [RFC7230]). +func (c *Controller) Trace() { + ts := func(h http.Header) (hs string) { + for k, v := range h { + hs += fmt.Sprintf("\r\n%s: %s", k, v) + } + return + } + hs := fmt.Sprintf("\r\nTRACE %s %s%s\r\n", c.Ctx.Request.RequestURI, c.Ctx.Request.Proto, ts(c.Ctx.Request.Header)) + c.Ctx.Output.Header("Content-Type", "message/http") + c.Ctx.Output.Header("Content-Length", fmt.Sprint(len(hs))) + c.Ctx.WriteString(hs) +} + // HandlerFunc call function with the name func (c *Controller) HandlerFunc(fnname string) bool { if v, ok := c.methodMapping[fnname]; ok { @@ -342,7 +371,7 @@ func (c *Controller) URLFor(endpoint string, values ...interface{}) string { return "" } if endpoint[0] == '.' { - return URLFor(reflect.Indirect(reflect.ValueOf(c.AppController)).Type().Name()+endpoint, values...) + return URLFor(reflect.Indirect(reflect.ValueOf(c.AppController)).Type().Name() + endpoint, values...) } return URLFor(endpoint, values...) } @@ -350,7 +379,7 @@ func (c *Controller) URLFor(endpoint string, values ...interface{}) string { // ServeJSON sends a json response with encoding charset. func (c *Controller) ServeJSON(encoding ...bool) { var ( - hasIndent = BConfig.RunMode != PROD + hasIndent = BConfig.RunMode != PROD hasEncoding = len(encoding) > 0 && encoding[0] ) @@ -575,7 +604,7 @@ func (c *Controller) SaveToFile(fromfile, tofile string) error { return err } defer file.Close() - f, err := os.OpenFile(tofile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666) + f, err := os.OpenFile(tofile, os.O_WRONLY | os.O_CREATE | os.O_TRUNC, 0666) if err != nil { return err } diff --git a/router.go b/router.go index a9b6f078..c7abe38c 100644 --- a/router.go +++ b/router.go @@ -843,6 +843,8 @@ func (p *ControllerRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request) execController.Patch() case http.MethodOptions: execController.Options() + case http.MethodTrace: + execController.Trace() default: if !execController.HandlerFunc(runMethod) { vc := reflect.ValueOf(execController) From 02bead509778356b010c8ef08f1fdee139e44d6f Mon Sep 17 00:00:00 2001 From: JessonChan Date: Wed, 27 Mar 2019 13:40:34 +0800 Subject: [PATCH 02/13] handle trace request must NOT CACHE https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Cache-Control --- controller.go | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/controller.go b/controller.go index e6ecd12e..c1bbb857 100644 --- a/controller.go +++ b/controller.go @@ -93,17 +93,17 @@ func (p ControllerCommentsSlice) Swap(i, j int) { // Controller defines some basic http request handler operations, such as // http context, template and view, session and xsrf. type Controller struct { - // context data - Ctx *context.Context - Data map[interface{}]interface{} + // context data + Ctx *context.Context + Data map[interface{}]interface{} - // route controller info + // route controller info controllerName string actionName string methodMapping map[string]func() //method:routertree AppController interface{} - // template data + // template data TplName string ViewPath string Layout string @@ -112,13 +112,13 @@ type Controller struct { TplExt string EnableRender bool - // xsrf data - _xsrfToken string - XSRFExpire int - EnableXSRF bool + // xsrf data + _xsrfToken string + XSRFExpire int + EnableXSRF bool - // session - CruSession session.Store + // session + CruSession session.Store } // ControllerInterface is an interface to uniform all controller handler. @@ -214,6 +214,7 @@ func (c *Controller) Trace() { hs := fmt.Sprintf("\r\nTRACE %s %s%s\r\n", c.Ctx.Request.RequestURI, c.Ctx.Request.Proto, ts(c.Ctx.Request.Header)) c.Ctx.Output.Header("Content-Type", "message/http") c.Ctx.Output.Header("Content-Length", fmt.Sprint(len(hs))) + c.Ctx.Output.Header("Cache-Control", "no-cache, no-store, must-revalidate") c.Ctx.WriteString(hs) } @@ -371,7 +372,7 @@ func (c *Controller) URLFor(endpoint string, values ...interface{}) string { return "" } if endpoint[0] == '.' { - return URLFor(reflect.Indirect(reflect.ValueOf(c.AppController)).Type().Name() + endpoint, values...) + return URLFor(reflect.Indirect(reflect.ValueOf(c.AppController)).Type().Name()+endpoint, values...) } return URLFor(endpoint, values...) } @@ -379,7 +380,7 @@ func (c *Controller) URLFor(endpoint string, values ...interface{}) string { // ServeJSON sends a json response with encoding charset. func (c *Controller) ServeJSON(encoding ...bool) { var ( - hasIndent = BConfig.RunMode != PROD + hasIndent = BConfig.RunMode != PROD hasEncoding = len(encoding) > 0 && encoding[0] ) @@ -604,7 +605,7 @@ func (c *Controller) SaveToFile(fromfile, tofile string) error { return err } defer file.Close() - f, err := os.OpenFile(tofile, os.O_WRONLY | os.O_CREATE | os.O_TRUNC, 0666) + f, err := os.OpenFile(tofile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666) if err != nil { return err } From 3155f07ccdcdd7d3fc0e5ebcf022e834b7e24688 Mon Sep 17 00:00:00 2001 From: JessonChan Date: Wed, 27 Mar 2019 13:43:27 +0800 Subject: [PATCH 03/13] no need to override Trace method. --- controller.go | 1 + 1 file changed, 1 insertion(+) diff --git a/controller.go b/controller.go index c1bbb857..38328c17 100644 --- a/controller.go +++ b/controller.go @@ -198,6 +198,7 @@ func (c *Controller) Options() { } // Trace adds a request function to handle Trace request. +// this method SHOULD NOT be overridden. // https://tools.ietf.org/html/rfc7231#section-4.3.8 // The TRACE method requests a remote, application-level loop-back of // the request message. The final recipient of the request SHOULD From 75b4bc58965a6b3d8172df7b4b5f34904d04b9a9 Mon Sep 17 00:00:00 2001 From: JessonChan Date: Wed, 3 Apr 2019 10:19:09 +0800 Subject: [PATCH 04/13] it's no need to override Trace method. --- controller.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/controller.go b/controller.go index 38328c17..0e8853b3 100644 --- a/controller.go +++ b/controller.go @@ -17,6 +17,7 @@ package beego import ( "bytes" "errors" + "fmt" "html/template" "io" "mime/multipart" @@ -27,8 +28,6 @@ import ( "strconv" "strings" - "fmt" - "github.com/astaxie/beego/context" "github.com/astaxie/beego/context/param" "github.com/astaxie/beego/session" @@ -80,15 +79,9 @@ type ControllerComments struct { // ControllerCommentsSlice implements the sort interface type ControllerCommentsSlice []ControllerComments -func (p ControllerCommentsSlice) Len() int { - return len(p) -} -func (p ControllerCommentsSlice) Less(i, j int) bool { - return p[i].Router < p[j].Router -} -func (p ControllerCommentsSlice) Swap(i, j int) { - p[i], p[j] = p[j], p[i] -} +func (p ControllerCommentsSlice) Len() int { return len(p) } +func (p ControllerCommentsSlice) Less(i, j int) bool { return p[i].Router < p[j].Router } +func (p ControllerCommentsSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } // Controller defines some basic http request handler operations, such as // http context, template and view, session and xsrf. From e3d668f4504b04a8bd78ea36d95cdf7d09df164a Mon Sep 17 00:00:00 2001 From: JessonChan Date: Wed, 3 Apr 2019 14:08:42 +0800 Subject: [PATCH 05/13] revet to log.go https://github.com/astaxie/beego/issues/3591 https://github.com/astaxie/beego/issues/3588 --- log.go | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 log.go diff --git a/log.go b/log.go new file mode 100644 index 00000000..e9412f92 --- /dev/null +++ b/log.go @@ -0,0 +1,111 @@ +// Copyright 2014 beego Author. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package beego + +import ( + "strings" + + "github.com/astaxie/beego/logs" +) + +// Log levels to control the logging output. +const ( + LevelEmergency = iota + LevelAlert + LevelCritical + LevelError + LevelWarning + LevelNotice + LevelInformational + LevelDebug +) + +// BeeLogger references the used application logger. +var BeeLogger = logs.GetBeeLogger() + +// SetLevel sets the global log level used by the simple logger. +func SetLevel(l int) { + logs.SetLevel(l) +} + +// SetLogFuncCall set the CallDepth, default is 3 +func SetLogFuncCall(b bool) { + logs.SetLogFuncCall(b) +} + +// SetLogger sets a new logger. +func SetLogger(adaptername string, config string) error { + return logs.SetLogger(adaptername, config) +} + +// Emergency logs a message at emergency level. +func Emergency(v ...interface{}) { + logs.Emergency(generateFmtStr(len(v)), v...) +} + +// Alert logs a message at alert level. +func Alert(v ...interface{}) { + logs.Alert(generateFmtStr(len(v)), v...) +} + +// Critical logs a message at critical level. +func Critical(v ...interface{}) { + logs.Critical(generateFmtStr(len(v)), v...) +} + +// Error logs a message at error level. +func Error(v ...interface{}) { + logs.Error(generateFmtStr(len(v)), v...) +} + +// Warning logs a message at warning level. +func Warning(v ...interface{}) { + logs.Warning(generateFmtStr(len(v)), v...) +} + +// Warn compatibility alias for Warning() +func Warn(v ...interface{}) { + logs.Warn(generateFmtStr(len(v)), v...) +} + +// Notice logs a message at notice level. +func Notice(v ...interface{}) { + logs.Notice(generateFmtStr(len(v)), v...) +} + +// Informational logs a message at info level. +func Informational(v ...interface{}) { + logs.Informational(generateFmtStr(len(v)), v...) +} + +// Info compatibility alias for Warning() +func Info(v ...interface{}) { + logs.Info(generateFmtStr(len(v)), v...) +} + +// Debug logs a message at debug level. +func Debug(v ...interface{}) { + logs.Debug(generateFmtStr(len(v)), v...) +} + +// Trace logs a message at trace level. +// compatibility alias for Warning() +func Trace(v ...interface{}) { + logs.Trace(generateFmtStr(len(v)), v...) +} + +func generateFmtStr(n int) string { + return strings.Repeat("%v ", n) +} From ce3800e3efcb40f219d27e5ff4a2a4800aa6f229 Mon Sep 17 00:00:00 2001 From: JessonChan Date: Wed, 3 Apr 2019 14:13:38 +0800 Subject: [PATCH 06/13] // Deprecated: use github.com/astaxie/beego/logs instead. --- log.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/log.go b/log.go index e9412f92..cc4c0f81 100644 --- a/log.go +++ b/log.go @@ -21,6 +21,7 @@ import ( ) // Log levels to control the logging output. +// Deprecated: use github.com/astaxie/beego/logs instead. const ( LevelEmergency = iota LevelAlert @@ -33,75 +34,90 @@ const ( ) // BeeLogger references the used application logger. +// Deprecated: use github.com/astaxie/beego/logs instead. var BeeLogger = logs.GetBeeLogger() // SetLevel sets the global log level used by the simple logger. +// Deprecated: use github.com/astaxie/beego/logs instead. func SetLevel(l int) { logs.SetLevel(l) } // SetLogFuncCall set the CallDepth, default is 3 +// Deprecated: use github.com/astaxie/beego/logs instead. func SetLogFuncCall(b bool) { logs.SetLogFuncCall(b) } // SetLogger sets a new logger. +// Deprecated: use github.com/astaxie/beego/logs instead. func SetLogger(adaptername string, config string) error { return logs.SetLogger(adaptername, config) } // Emergency logs a message at emergency level. +// Deprecated: use github.com/astaxie/beego/logs instead. func Emergency(v ...interface{}) { logs.Emergency(generateFmtStr(len(v)), v...) } // Alert logs a message at alert level. +// Deprecated: use github.com/astaxie/beego/logs instead. func Alert(v ...interface{}) { logs.Alert(generateFmtStr(len(v)), v...) } // Critical logs a message at critical level. +// Deprecated: use github.com/astaxie/beego/logs instead. func Critical(v ...interface{}) { logs.Critical(generateFmtStr(len(v)), v...) } // Error logs a message at error level. +// Deprecated: use github.com/astaxie/beego/logs instead. func Error(v ...interface{}) { logs.Error(generateFmtStr(len(v)), v...) } // Warning logs a message at warning level. +// Deprecated: use github.com/astaxie/beego/logs instead. func Warning(v ...interface{}) { logs.Warning(generateFmtStr(len(v)), v...) } // Warn compatibility alias for Warning() +// Deprecated: use github.com/astaxie/beego/logs instead. func Warn(v ...interface{}) { logs.Warn(generateFmtStr(len(v)), v...) } // Notice logs a message at notice level. +// Deprecated: use github.com/astaxie/beego/logs instead. func Notice(v ...interface{}) { logs.Notice(generateFmtStr(len(v)), v...) } // Informational logs a message at info level. +// Deprecated: use github.com/astaxie/beego/logs instead. func Informational(v ...interface{}) { logs.Informational(generateFmtStr(len(v)), v...) } // Info compatibility alias for Warning() +// Deprecated: use github.com/astaxie/beego/logs instead. func Info(v ...interface{}) { logs.Info(generateFmtStr(len(v)), v...) } // Debug logs a message at debug level. +// Deprecated: use github.com/astaxie/beego/logs instead. func Debug(v ...interface{}) { logs.Debug(generateFmtStr(len(v)), v...) } // Trace logs a message at trace level. // compatibility alias for Warning() +// Deprecated: use github.com/astaxie/beego/logs instead. func Trace(v ...interface{}) { logs.Trace(generateFmtStr(len(v)), v...) } From 190024605408b1a9964da201a022f7a1bc04cf36 Mon Sep 17 00:00:00 2001 From: Wusuluren <1634636348@qq.com> Date: Fri, 5 Apr 2019 22:15:53 +0800 Subject: [PATCH 07/13] fix bug on cache/file --- cache/file.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cache/file.go b/cache/file.go index 1926268a..6f12d3ee 100644 --- a/cache/file.go +++ b/cache/file.go @@ -62,11 +62,14 @@ func NewFileCache() Cache { } // StartAndGC will start and begin gc for file cache. -// the config need to be like {CachePath:"/cache","FileSuffix":".bin","DirectoryLevel":2,"EmbedExpiry":0} +// the config need to be like {CachePath:"/cache","FileSuffix":".bin","DirectoryLevel":"2","EmbedExpiry":"0"} func (fc *FileCache) StartAndGC(config string) error { cfg := make(map[string]string) - json.Unmarshal([]byte(config), &cfg) + err := json.Unmarshal([]byte(config), &cfg) + if err != nil { + return err + } if _, ok := cfg["CachePath"]; !ok { cfg["CachePath"] = FileCachePath } @@ -142,12 +145,12 @@ func (fc *FileCache) GetMulti(keys []string) []interface{} { // Put value into file cache. // timeout means how long to keep this file, unit of ms. -// if timeout equals FileCacheEmbedExpiry(default is 0), cache this item forever. +// if timeout equals fc.EmbedExpiry(default is 0), cache this item forever. func (fc *FileCache) Put(key string, val interface{}, timeout time.Duration) error { gob.Register(val) item := FileCacheItem{Data: val} - if timeout == FileCacheEmbedExpiry { + if timeout == time.Duration(fc.EmbedExpiry) { item.Expired = time.Now().Add((86400 * 365 * 10) * time.Second) // ten years } else { item.Expired = time.Now().Add(timeout) @@ -179,7 +182,7 @@ func (fc *FileCache) Incr(key string) error { } else { incr = data.(int) + 1 } - fc.Put(key, incr, FileCacheEmbedExpiry) + fc.Put(key, incr, time.Duration(fc.EmbedExpiry)) return nil } @@ -192,7 +195,7 @@ func (fc *FileCache) Decr(key string) error { } else { decr = data.(int) - 1 } - fc.Put(key, decr, FileCacheEmbedExpiry) + fc.Put(key, decr, time.Duration(fc.EmbedExpiry)) return nil } From dfab44c24ab4573adccbf0dcc998f4cde5fca919 Mon Sep 17 00:00:00 2001 From: Wusuluren <1634636348@qq.com> Date: Fri, 5 Apr 2019 22:32:28 +0800 Subject: [PATCH 08/13] fix bug on cache/file --- cache/cache_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cache/cache_test.go b/cache/cache_test.go index 9ceb606a..1e71d075 100644 --- a/cache/cache_test.go +++ b/cache/cache_test.go @@ -98,7 +98,7 @@ func TestCache(t *testing.T) { } func TestFileCache(t *testing.T) { - bm, err := NewCache("file", `{"CachePath":"cache","FileSuffix":".bin","DirectoryLevel":2,"EmbedExpiry":0}`) + bm, err := NewCache("file", `{"CachePath":"cache","FileSuffix":".bin","DirectoryLevel":"2","EmbedExpiry":"0"}`) if err != nil { t.Error("init err") } From 3086081ec02803c7cb73fc7c40b7c656698b36dc Mon Sep 17 00:00:00 2001 From: astaxie Date: Sat, 6 Apr 2019 13:50:14 +0800 Subject: [PATCH 09/13] v1.11.2 --- beego.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beego.go b/beego.go index ff89f2f5..7ebea8a2 100644 --- a/beego.go +++ b/beego.go @@ -23,7 +23,7 @@ import ( const ( // VERSION represent beego web framework version. - VERSION = "1.11.1" + VERSION = "1.11.2" // DEV is for develop DEV = "dev" From fa97488bdc130ae71abb09a0f769f76ad78586ed Mon Sep 17 00:00:00 2001 From: guanle <270464839@qq.com> Date: Sun, 21 Apr 2019 10:27:35 +0800 Subject: [PATCH 10/13] Update templatefunc.go --- templatefunc.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/templatefunc.go b/templatefunc.go index 5ef9a041..d62442ae 100644 --- a/templatefunc.go +++ b/templatefunc.go @@ -300,7 +300,12 @@ func parseFormToStruct(form url.Values, objT reflect.Type, objV reflect.Value) e formValues := form[tag] var value string if len(formValues) == 0 { - continue + defaultValue := fieldT.Tag.Get("default") + if defaultValue != "" { + value = defaultValue + } else { + continue + } } if len(formValues) == 1 { value = formValues[0] From 0b165b78a1a00631eaf881f634c8aa8b15969f36 Mon Sep 17 00:00:00 2001 From: hetingyao Date: Mon, 22 Apr 2019 22:18:37 +0800 Subject: [PATCH 11/13] make routers configurable for beego multi-instance in the same repo --- parser.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/parser.go b/parser.go index 81990a4a..5e6b9111 100644 --- a/parser.go +++ b/parser.go @@ -35,7 +35,7 @@ import ( "github.com/astaxie/beego/utils" ) -var globalRouterTemplate = `package routers +var globalRouterTemplate = `package {{.routersDir}} import ( "github.com/astaxie/beego" @@ -516,7 +516,9 @@ func genRouterCode(pkgRealpath string) { } defer f.Close() + routersDir := AppConfig.DefaultString("routersdir", "routers") content := strings.Replace(globalRouterTemplate, "{{.globalinfo}}", globalinfo, -1) + content = strings.Replace(content, "{{.routersDir}}", routersDir, -1) content = strings.Replace(content, "{{.globalimport}}", globalimport, -1) f.WriteString(content) } @@ -574,7 +576,8 @@ func getpathTime(pkgRealpath string) (lastupdate int64, err error) { func getRouterDir(pkgRealpath string) string { dir := filepath.Dir(pkgRealpath) for { - d := filepath.Join(dir, "routers") + routersDir := AppConfig.DefaultString("routersdir", "routers") + d := filepath.Join(dir, routersDir) if utils.FileExists(d) { return d } From afb787d49db39d37047b48fbfa139bc7651dd973 Mon Sep 17 00:00:00 2001 From: Yang Luo Date: Sat, 27 Apr 2019 16:55:42 +0800 Subject: [PATCH 12/13] remove the 1000-row limit for ORM result set --- orm/orm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orm/orm.go b/orm/orm.go index fc3cd400..d322881b 100644 --- a/orm/orm.go +++ b/orm/orm.go @@ -72,7 +72,7 @@ const ( var ( Debug = false DebugLog = NewLog(os.Stdout) - DefaultRowsLimit = 1000 + DefaultRowsLimit = -1 DefaultRelsDepth = 2 DefaultTimeLoc = time.Local ErrTxHasBegan = errors.New(" transaction already begin") From a9629f707e37883b491e058e03dfb870543dda75 Mon Sep 17 00:00:00 2001 From: haley Date: Sun, 28 Apr 2019 08:50:30 +0800 Subject: [PATCH 13/13] route request put amendment --- router.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/router.go b/router.go index 997b6854..e00c1b36 100644 --- a/router.go +++ b/router.go @@ -779,7 +779,7 @@ func (p *ControllerRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request) runRouter = routerInfo.controllerType methodParams = routerInfo.methodParams method := r.Method - if r.Method == http.MethodPost && context.Input.Query("_method") == http.MethodPost { + if r.Method == http.MethodPost && context.Input.Query("_method") == http.MethodPut { method = http.MethodPut } if r.Method == http.MethodPost && context.Input.Query("_method") == http.MethodDelete {