From 4785ac14d73024ac11d357125c3e6ff47b5e3cb7 Mon Sep 17 00:00:00 2001 From: Kyle McCullough Date: Tue, 18 Mar 2014 18:00:07 -0500 Subject: [PATCH 01/27] allow unexported fields on model structs --- orm/models_info_m.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/orm/models_info_m.go b/orm/models_info_m.go index b596fc6a..4308c962 100644 --- a/orm/models_info_m.go +++ b/orm/models_info_m.go @@ -43,6 +43,9 @@ func newModelInfo(val reflect.Value) (info *modelInfo) { for i := 0; i < ind.NumField(); i++ { field := ind.Field(i) sf = ind.Type().Field(i) + if sf.PkgPath != "" { + continue + } fi, err = newFieldInfo(info, field, sf) if err != nil { From 18f70e6ee49c031de3bb6c0fe14148877713efcb Mon Sep 17 00:00:00 2001 From: Donald Zhan Date: Wed, 9 Apr 2014 12:39:12 +0800 Subject: [PATCH 02/27] update the error message --- cache/cache_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cache/cache_test.go b/cache/cache_test.go index bc484e0f..52612cfd 100644 --- a/cache/cache_test.go +++ b/cache/cache_test.go @@ -40,7 +40,7 @@ func TestCache(t *testing.T) { } if err = bm.Decr("astaxie"); err != nil { - t.Error("Incr Error", err) + t.Error("Decr Error", err) } if v := bm.Get("astaxie"); v.(int) != 1 { @@ -77,7 +77,7 @@ func TestFileCache(t *testing.T) { } if err = bm.Decr("astaxie"); err != nil { - t.Error("Incr Error", err) + t.Error("Decr Error", err) } if v := bm.Get("astaxie"); v.(int) != 1 { From 1bb876f2dfa4711858082cb888ddd5d986a3d95b Mon Sep 17 00:00:00 2001 From: Lin Luxiang Date: Tue, 8 Apr 2014 18:16:16 +0800 Subject: [PATCH 03/27] make Maxage work --- session/sess_cookie.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/session/sess_cookie.go b/session/sess_cookie.go index 54acba31..0fe7b093 100644 --- a/session/sess_cookie.go +++ b/session/sess_cookie.go @@ -73,7 +73,8 @@ func (st *CookieSessionStore) SessionRelease(w http.ResponseWriter) { Value: url.QueryEscape(str), Path: "/", HttpOnly: true, - Secure: cookiepder.config.Secure} + Secure: cookiepder.config.Secure, + MaxAge: cookiepder.config.Maxage} http.SetCookie(w, cookie) return } From 5a529497616ed6b558f76e246c0d90df020f88b1 Mon Sep 17 00:00:00 2001 From: astaxie Date: Wed, 9 Apr 2014 21:42:57 +0800 Subject: [PATCH 04/27] beego: support not-empty value in router fix #555 --- router.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/router.go b/router.go index e123ec55..aa10de2d 100644 --- a/router.go +++ b/router.go @@ -109,6 +109,10 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface, mappingM expr = `([\w]+)` part = part[:lindex] } + //marth /user/:id! non-empty value + } else if part[len(part)-1] == '!' { + expr = `(.+)` + part = part[:len(part)-1] } params[j] = part parts[i] = expr From 127b85bcaa826e9214a539d98a1e943ddfe6cd4c Mon Sep 17 00:00:00 2001 From: astaxie Date: Thu, 10 Apr 2014 00:31:16 +0800 Subject: [PATCH 05/27] context:add Bind function // Bind data from request.Form[key] to dest // like /?id=123&isok=true&ft=1.2&ol[0]=1&ol[1]=2&ul[]=str&ul[]=array&user.Name= astaxie // var id int beegoInput.Bind(&id, "id") id ==123 // var isok bool beegoInput.Bind(&isok, "isok") id ==true // var ft float64 beegoInput.Bind(&ft, "ft") ft ==1.2 // ol := make([]int, 0, 2) beegoInput.Bind(&ol, "ol") ol ==[1 2] // ul := make([]string, 0, 2) beegoInput.Bind(&ul, "ul") ul ==[str array] // user struct{Name} beegoInput.Bind(&user, "user") user == {Name:"astaxie"} --- context/input.go | 243 ++++++++++++++++++++++++++++++++++++++++++ context/input_test.go | 58 ++++++++++ 2 files changed, 301 insertions(+) create mode 100644 context/input_test.go diff --git a/context/input.go b/context/input.go index df0680e5..639c58c6 100644 --- a/context/input.go +++ b/context/input.go @@ -5,6 +5,7 @@ import ( "errors" "io/ioutil" "net/http" + "net/url" "reflect" "strconv" "strings" @@ -261,6 +262,7 @@ func (input *BeegoInput) SetData(key, val interface{}) { input.Data[key] = val } +// parseForm or parseMultiForm based on Content-type func (input *BeegoInput) ParseFormOrMulitForm(maxMemory int64) error { // Parse the body depending on the content type. switch input.Header("Content-Type") { @@ -278,3 +280,244 @@ func (input *BeegoInput) ParseFormOrMulitForm(maxMemory int64) error { return nil } + +// Bind data from request.Form[key] to dest +// like /?id=123&isok=true&ft=1.2&ol[0]=1&ol[1]=2&ul[]=str&ul[]=array&user.Name=astaxie +// var id int beegoInput.Bind(&id, "id") id ==123 +// var isok bool beegoInput.Bind(&isok, "isok") id ==true +// var ft float64 beegoInput.Bind(&ft, "ft") ft ==1.2 +// ol := make([]int, 0, 2) beegoInput.Bind(&ol, "ol") ol ==[1 2] +// ul := make([]string, 0, 2) beegoInput.Bind(&ul, "ul") ul ==[str array] +// user struct{Name} beegoInput.Bind(&user, "user") user == {Name:"astaxie"} +func (input *BeegoInput) Bind(dest interface{}, key string) error { + value := reflect.ValueOf(dest) + if value.Kind() != reflect.Ptr { + return errors.New("beego: non-pointer passed to Bind: " + key) + } + value = value.Elem() + if !value.CanSet() { + return errors.New("beego: non-settable variable passed to Bind: " + key) + } + rv := input.bind(key, value.Type()) + if !rv.IsValid() { + return errors.New("beego: reflect value is empty") + } + value.Set(rv) + return nil +} + +func (input *BeegoInput) bind(key string, typ reflect.Type) reflect.Value { + rv := reflect.Zero(reflect.TypeOf(0)) + switch typ.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + val := input.Query(key) + if len(val) == 0 { + return rv + } + rv = input.bindInt(val, typ) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + val := input.Query(key) + if len(val) == 0 { + return rv + } + rv = input.bindUint(val, typ) + case reflect.Float32, reflect.Float64: + val := input.Query(key) + if len(val) == 0 { + return rv + } + rv = input.bindFloat(val, typ) + case reflect.String: + val := input.Query(key) + if len(val) == 0 { + return rv + } + rv = input.bindString(val, typ) + case reflect.Bool: + val := input.Query(key) + if len(val) == 0 { + return rv + } + rv = input.bindBool(val, typ) + case reflect.Slice: + rv = input.bindSlice(&input.Request.Form, key, typ) + case reflect.Struct: + rv = input.bindStruct(&input.Request.Form, key, typ) + case reflect.Ptr: + rv = input.bindPoint(key, typ) + case reflect.Map: + rv = input.bindMap(&input.Request.Form, key, typ) + } + return rv +} + +func (input *BeegoInput) bindValue(val string, typ reflect.Type) reflect.Value { + rv := reflect.Zero(reflect.TypeOf(0)) + switch typ.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + rv = input.bindInt(val, typ) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + rv = input.bindUint(val, typ) + case reflect.Float32, reflect.Float64: + rv = input.bindFloat(val, typ) + case reflect.String: + rv = input.bindString(val, typ) + case reflect.Bool: + rv = input.bindBool(val, typ) + case reflect.Slice: + rv = input.bindSlice(&url.Values{"": {val}}, "", typ) + case reflect.Struct: + rv = input.bindStruct(&url.Values{"": {val}}, "", typ) + case reflect.Ptr: + rv = input.bindPoint(val, typ) + case reflect.Map: + rv = input.bindMap(&url.Values{"": {val}}, "", typ) + } + return rv +} + +func (input *BeegoInput) bindInt(val string, typ reflect.Type) reflect.Value { + intValue, err := strconv.ParseInt(val, 10, 64) + if err != nil { + return reflect.Zero(typ) + } + pValue := reflect.New(typ) + pValue.Elem().SetInt(intValue) + return pValue.Elem() +} + +func (input *BeegoInput) bindUint(val string, typ reflect.Type) reflect.Value { + uintValue, err := strconv.ParseUint(val, 10, 64) + if err != nil { + return reflect.Zero(typ) + } + pValue := reflect.New(typ) + pValue.Elem().SetUint(uintValue) + return pValue.Elem() +} + +func (input *BeegoInput) bindFloat(val string, typ reflect.Type) reflect.Value { + floatValue, err := strconv.ParseFloat(val, 64) + if err != nil { + return reflect.Zero(typ) + } + pValue := reflect.New(typ) + pValue.Elem().SetFloat(floatValue) + return pValue.Elem() +} + +func (input *BeegoInput) bindString(val string, typ reflect.Type) reflect.Value { + return reflect.ValueOf(val) +} + +func (input *BeegoInput) bindBool(val string, typ reflect.Type) reflect.Value { + val = strings.TrimSpace(strings.ToLower(val)) + switch val { + case "true", "on", "1": + return reflect.ValueOf(true) + } + return reflect.ValueOf(false) +} + +type sliceValue struct { + index int // Index extracted from brackets. If -1, no index was provided. + value reflect.Value // the bound value for this slice element. +} + +func (input *BeegoInput) bindSlice(params *url.Values, key string, typ reflect.Type) reflect.Value { + maxIndex := -1 + numNoIndex := 0 + sliceValues := []sliceValue{} + for reqKey, vals := range *params { + if !strings.HasPrefix(reqKey, key+"[") { + continue + } + // Extract the index, and the index where a sub-key starts. (e.g. field[0].subkey) + index := -1 + leftBracket, rightBracket := len(key), strings.Index(reqKey[len(key):], "]")+len(key) + if rightBracket > leftBracket+1 { + index, _ = strconv.Atoi(reqKey[leftBracket+1 : rightBracket]) + } + subKeyIndex := rightBracket + 1 + + // Handle the indexed case. + if index > -1 { + if index > maxIndex { + maxIndex = index + } + sliceValues = append(sliceValues, sliceValue{ + index: index, + value: input.bind(reqKey[:subKeyIndex], typ.Elem()), + }) + continue + } + + // It's an un-indexed element. (e.g. element[]) + numNoIndex += len(vals) + for _, val := range vals { + // Unindexed values can only be direct-bound. + sliceValues = append(sliceValues, sliceValue{ + index: -1, + value: input.bindValue(val, typ.Elem()), + }) + } + } + resultArray := reflect.MakeSlice(typ, maxIndex+1, maxIndex+1+numNoIndex) + for _, sv := range sliceValues { + if sv.index != -1 { + resultArray.Index(sv.index).Set(sv.value) + } else { + resultArray = reflect.Append(resultArray, sv.value) + } + } + return resultArray +} + +func (input *BeegoInput) bindStruct(params *url.Values, key string, typ reflect.Type) reflect.Value { + result := reflect.New(typ).Elem() + fieldValues := make(map[string]reflect.Value) + for reqKey, val := range *params { + if !strings.HasPrefix(reqKey, key+".") { + continue + } + + fieldName := reqKey[len(key)+1:] + + if _, ok := fieldValues[fieldName]; !ok { + // Time to bind this field. Get it and make sure we can set it. + fieldValue := result.FieldByName(fieldName) + if !fieldValue.IsValid() { + continue + } + if !fieldValue.CanSet() { + continue + } + boundVal := input.bindValue(val[0], fieldValue.Type()) + fieldValue.Set(boundVal) + fieldValues[fieldName] = boundVal + } + } + + return result +} + +func (input *BeegoInput) bindPoint(key string, typ reflect.Type) reflect.Value { + return input.bind(key, typ.Elem()).Addr() +} + +func (input *BeegoInput) bindMap(params *url.Values, key string, typ reflect.Type) reflect.Value { + var ( + result = reflect.MakeMap(typ) + keyType = typ.Key() + valueType = typ.Elem() + ) + for paramName, values := range *params { + if !strings.HasPrefix(paramName, key+"[") || paramName[len(paramName)-1] != ']' { + continue + } + + key := paramName[len(key)+1 : len(paramName)-1] + result.SetMapIndex(input.bindValue(key, keyType), input.bindValue(values[0], valueType)) + } + return result +} diff --git a/context/input_test.go b/context/input_test.go new file mode 100644 index 00000000..26e95982 --- /dev/null +++ b/context/input_test.go @@ -0,0 +1,58 @@ +package context + +import ( + "fmt" + "net/http" + "testing" +) + +func TestParse(t *testing.T) { + r, _ := http.NewRequest("GET", "/?id=123&isok=true&ft=1.2&ol[0]=1&ol[1]=2&ul[]=str&ul[]=array&user.Name=astaxie", nil) + beegoInput := NewInput(r) + beegoInput.ParseFormOrMulitForm(1 << 20) + + var id int + err := beegoInput.Bind(&id, "id") + if id != 123 || err != nil { + t.Fatal("id should has int value") + } + fmt.Println(id) + + var isok bool + err = beegoInput.Bind(&isok, "isok") + if !isok || err != nil { + t.Fatal("isok should be true") + } + fmt.Println(isok) + + var float float64 + err = beegoInput.Bind(&float, "ft") + if float != 1.2 || err != nil { + t.Fatal("float should be equal to 1.2") + } + fmt.Println(float) + + ol := make([]int, 0, 2) + err = beegoInput.Bind(&ol, "ol") + if len(ol) != 2 || err != nil || ol[0] != 1 || ol[1] != 2 { + t.Fatal("ol should has two elements") + } + fmt.Println(ol) + + ul := make([]string, 0, 2) + err = beegoInput.Bind(&ul, "ul") + if len(ul) != 2 || err != nil || ul[0] != "str" || ul[1] != "array" { + t.Fatal("ul should has two elements") + } + fmt.Println(ul) + + type User struct { + Name string + } + user := User{} + err = beegoInput.Bind(&user, "user") + if err != nil || user.Name != "astaxie" { + t.Fatal("user should has name") + } + fmt.Println(user) +} From e50cbecf8019c7bd2e797b1ce8157fa9e9957453 Mon Sep 17 00:00:00 2001 From: astaxie Date: Thu, 10 Apr 2014 18:14:18 +0800 Subject: [PATCH 06/27] beego: fix flash errors --- flash.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flash.go b/flash.go index 3cb4a66a..8adb004b 100644 --- a/flash.go +++ b/flash.go @@ -64,7 +64,7 @@ func ReadFromRequest(c *Controller) *FlashData { vals := strings.Split(v, "\x00") for _, v := range vals { if len(v) > 0 { - kv := strings.Split(v, FlashSeperator) + kv := strings.Split(v, "\x23"+FlashSeperator+"\x23") if len(kv) == 2 { flash.Data[kv[0]] = kv[1] } From b212ec8dab599f1513467c5a327ccea5e9fbd96f Mon Sep 17 00:00:00 2001 From: astaxie Date: Thu, 10 Apr 2014 22:20:46 +0800 Subject: [PATCH 07/27] beego:query data from Form & params --- context/input.go | 3 +++ controller.go | 13 +++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/context/input.go b/context/input.go index 639c58c6..1f093c01 100644 --- a/context/input.go +++ b/context/input.go @@ -212,6 +212,9 @@ func (input *BeegoInput) Param(key string) string { // Query returns input data item string by a given string. func (input *BeegoInput) Query(key string) string { + if val := input.Param(key); val != "" { + return val + } if input.Request.Form == nil { input.Request.ParseForm() } diff --git a/controller.go b/controller.go index 16bef4df..f2e2fa69 100644 --- a/controller.go +++ b/controller.go @@ -285,10 +285,7 @@ func (c *Controller) ServeXml() { // Input returns the input data map from POST or PUT request body and query string. func (c *Controller) Input() url.Values { - ct := c.Ctx.Request.Header.Get("Content-Type") - if strings.Contains(ct, "multipart/form-data") { - c.Ctx.Request.ParseMultipartForm(MaxMemory) //64MB - } else { + if c.Ctx.Request.Form == nil { c.Ctx.Request.ParseForm() } return c.Ctx.Request.Form @@ -301,7 +298,7 @@ func (c *Controller) ParseForm(obj interface{}) error { // GetString returns the input value by key string. func (c *Controller) GetString(key string) string { - return c.Input().Get(key) + return c.Ctx.Input.Query(key) } // GetStrings returns the input string slice by key string. @@ -320,17 +317,17 @@ func (c *Controller) GetStrings(key string) []string { // GetInt returns input value as int64. func (c *Controller) GetInt(key string) (int64, error) { - return strconv.ParseInt(c.Input().Get(key), 10, 64) + return strconv.ParseInt(c.Ctx.Input.Query(key), 10, 64) } // GetBool returns input value as bool. func (c *Controller) GetBool(key string) (bool, error) { - return strconv.ParseBool(c.Input().Get(key)) + return strconv.ParseBool(c.Ctx.Input.Query(key)) } // GetFloat returns input value as float64. func (c *Controller) GetFloat(key string) (float64, error) { - return strconv.ParseFloat(c.Input().Get(key), 64) + return strconv.ParseFloat(c.Ctx.Input.Query(key), 64) } // GetFile returns the file data in file upload field named as key. From 1ea449aa3a61129870147b4443b1b62b10a1dc53 Mon Sep 17 00:00:00 2001 From: astaxie Date: Thu, 10 Apr 2014 22:33:32 +0800 Subject: [PATCH 08/27] beego:add post test case --- router_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/router_test.go b/router_test.go index c1a7f213..2f500835 100644 --- a/router_test.go +++ b/router_test.go @@ -15,6 +15,10 @@ func (this *TestController) Get() { this.Ctx.Output.Body([]byte("ok")) } +func (this *TestController) Post() { + this.Ctx.Output.Body([]byte(this.Ctx.Input.Query(":name"))) +} + func (this *TestController) List() { this.Ctx.Output.Body([]byte("i am list")) } @@ -81,6 +85,18 @@ func TestUserFunc(t *testing.T) { } } +func TestPostFunc(t *testing.T) { + r, _ := http.NewRequest("POST", "/astaxie", nil) + w := httptest.NewRecorder() + + handler := NewControllerRegistor() + handler.Add("/:name", &TestController{}) + handler.ServeHTTP(w, r) + if w.Body.String() != "astaxie" { + t.Errorf("post func should astaxie") + } +} + func TestAutoFunc(t *testing.T) { r, _ := http.NewRequest("GET", "/test/list", nil) w := httptest.NewRecorder() From 8bcf03c6522415e5b0f8b1c73cf03ea276acf9e3 Mon Sep 17 00:00:00 2001 From: astaxie Date: Fri, 11 Apr 2014 16:08:43 +0800 Subject: [PATCH 09/27] fix #576 --- admin.go | 2 +- cache/memcache/memcache.go | 1 - config/json.go | 6 ------ controller.go | 4 ---- logs/file.go | 2 +- memzipfile.go | 1 - orm/db.go | 5 ----- orm/db_utils.go | 1 - orm/models_test.go | 3 +-- orm/orm.go | 4 +--- orm/orm_queryset.go | 2 -- orm/orm_test.go | 8 ++++---- orm/utils.go | 1 - reload.go | 3 +-- router.go | 1 - session/couchbase/sess_couchbase.go | 1 - session/mysql/sess_mysql.go | 1 - session/postgres/sess_postgresql.go | 1 - session/redis/sess_redis.go | 1 - session/sess_cookie.go | 1 - session/sess_file.go | 1 - session/sess_mem.go | 3 --- session/sess_utils.go | 2 -- toolbox/profile.go | 2 +- 24 files changed, 10 insertions(+), 47 deletions(-) diff --git a/admin.go b/admin.go index 1cab32e0..3a0d782a 100644 --- a/admin.go +++ b/admin.go @@ -232,7 +232,7 @@ func runTask(rw http.ResponseWriter, req *http.Request) { if err != nil { fmt.Fprintf(rw, "%v", err) } - fmt.Fprintf(rw, "%s run success,Now the Status is %s", t.GetStatus()) + fmt.Fprintf(rw, "%s run success,Now the Status is %s", taskname, t.GetStatus()) } else { fmt.Fprintf(rw, "there's no task which named:%s", taskname) } diff --git a/cache/memcache/memcache.go b/cache/memcache/memcache.go index 130405c4..bd5ab269 100644 --- a/cache/memcache/memcache.go +++ b/cache/memcache/memcache.go @@ -105,7 +105,6 @@ func (rc *MemcacheCache) IsExist(key string) bool { } else { return true } - return true } // clear all cached in memcache. diff --git a/config/json.go b/config/json.go index 24874e8a..3e3d1d35 100644 --- a/config/json.go +++ b/config/json.go @@ -53,7 +53,6 @@ func (c *JsonConfigContainer) Bool(key string) (bool, error) { } else { return false, errors.New("not exist key:" + key) } - return false, nil } // Int returns the integer value for a given key. @@ -68,7 +67,6 @@ func (c *JsonConfigContainer) Int(key string) (int, error) { } else { return 0, errors.New("not exist key:" + key) } - return 0, nil } // Int64 returns the int64 value for a given key. @@ -83,7 +81,6 @@ func (c *JsonConfigContainer) Int64(key string) (int64, error) { } else { return 0, errors.New("not exist key:" + key) } - return 0, nil } // Float returns the float value for a given key. @@ -98,7 +95,6 @@ func (c *JsonConfigContainer) Float(key string) (float64, error) { } else { return 0.0, errors.New("not exist key:" + key) } - return 0.0, nil } // String returns the string value for a given key. @@ -113,7 +109,6 @@ func (c *JsonConfigContainer) String(key string) string { } else { return "" } - return "" } // Strings returns the []string value for a given key. @@ -137,7 +132,6 @@ func (c *JsonConfigContainer) DIY(key string) (v interface{}, err error) { } else { return nil, errors.New("not exist key") } - return nil, nil } // section.key or key diff --git a/controller.go b/controller.go index f2e2fa69..34b7febd 100644 --- a/controller.go +++ b/controller.go @@ -153,7 +153,6 @@ func (c *Controller) RenderBytes() ([]byte, error) { newbytes := bytes.NewBufferString("") if _, ok := BeeTemplates[c.TplNames]; !ok { panic("can't find templatefile in the path:" + c.TplNames) - return []byte{}, errors.New("can't find templatefile in the path:" + c.TplNames) } err := BeeTemplates[c.TplNames].ExecuteTemplate(newbytes, c.TplNames, c.Data) if err != nil { @@ -199,7 +198,6 @@ func (c *Controller) RenderBytes() ([]byte, error) { ibytes := bytes.NewBufferString("") if _, ok := BeeTemplates[c.TplNames]; !ok { panic("can't find templatefile in the path:" + c.TplNames) - return []byte{}, errors.New("can't find templatefile in the path:" + c.TplNames) } err := BeeTemplates[c.TplNames].ExecuteTemplate(ibytes, c.TplNames, c.Data) if err != nil { @@ -209,7 +207,6 @@ func (c *Controller) RenderBytes() ([]byte, error) { icontent, _ := ioutil.ReadAll(ibytes) return icontent, nil } - return []byte{}, nil } // Redirect sends the redirection response to url with status code. @@ -243,7 +240,6 @@ func (c *Controller) UrlFor(endpoint string, values ...string) string { } else { return UrlFor(endpoint, values...) } - return "" } // ServeJson sends a json response with encoding charset. diff --git a/logs/file.go b/logs/file.go index 9400e04d..4c560330 100644 --- a/logs/file.go +++ b/logs/file.go @@ -30,7 +30,7 @@ type FileLogWriter struct { // Rotate daily Daily bool `json:"daily"` - Maxdays int64 `json:"maxdays` + Maxdays int64 `json:"maxdays"` daily_opendate int Rotate bool `json:"rotate"` diff --git a/memzipfile.go b/memzipfile.go index c62e2bc4..50c3205f 100644 --- a/memzipfile.go +++ b/memzipfile.go @@ -195,5 +195,4 @@ func getAcceptEncodingZip(r *http.Request) string { } else { return "" } - return "" } diff --git a/orm/db.go b/orm/db.go index dfb53621..e84062e8 100644 --- a/orm/db.go +++ b/orm/db.go @@ -446,7 +446,6 @@ func (d *dbBase) Update(q dbQuerier, mi *modelInfo, ind reflect.Value, tz *time. } else { return 0, err } - return 0, nil } // execute delete sql dbQuerier with given struct reflect.Value. @@ -489,7 +488,6 @@ func (d *dbBase) Delete(q dbQuerier, mi *modelInfo, ind reflect.Value, tz *time. } else { return 0, err } - return 0, nil } // update table-related record by querySet. @@ -566,7 +564,6 @@ func (d *dbBase) UpdateBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Con } else { return 0, err } - return 0, nil } // delete related records. @@ -671,8 +668,6 @@ func (d *dbBase) DeleteBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Con } else { return 0, err } - - return 0, nil } // read related records. diff --git a/orm/db_utils.go b/orm/db_utils.go index 3c8d2d23..da7c9976 100644 --- a/orm/db_utils.go +++ b/orm/db_utils.go @@ -13,7 +13,6 @@ func getDbAlias(name string) *alias { } else { panic(fmt.Errorf("unknown DataBase alias name %s", name)) } - return nil } // get pk column info. diff --git a/orm/models_test.go b/orm/models_test.go index e37e53d9..7f845721 100644 --- a/orm/models_test.go +++ b/orm/models_test.go @@ -83,7 +83,6 @@ func (e *JsonField) SetRaw(value interface{}) error { default: return fmt.Errorf(" unknown value `%v`", value) } - return nil } func (e *JsonField) RawValue() interface{} { @@ -122,7 +121,7 @@ type DataNull struct { Char string `orm:"null;size(50)"` Text string `orm:"null;type(text)"` Date time.Time `orm:"null;type(date)"` - DateTime time.Time `orm:"null;column(datetime)""` + DateTime time.Time `orm:"null;column(datetime)"` Byte byte `orm:"null"` Rune rune `orm:"null"` Int int `orm:"null"` diff --git a/orm/orm.go b/orm/orm.go index 25857fa8..920d7f40 100644 --- a/orm/orm.go +++ b/orm/orm.go @@ -293,7 +293,7 @@ func (o *orm) queryRelated(md interface{}, name string) (*modelInfo, *fieldInfo, } if qs == nil { - panic(fmt.Errorf(" name `%s` for model `%s` is not an available rel/reverse field")) + panic(fmt.Errorf(" name `%s` for model `%s` is not an available rel/reverse field", md, name)) } return mi, fi, ind, qs @@ -441,8 +441,6 @@ func (o *orm) Driver() Driver { func (o *orm) GetDB() dbQuerier { panic(ErrNotImplement) - // not enough - return o.db } // create new orm diff --git a/orm/orm_queryset.go b/orm/orm_queryset.go index d16f8eb5..f21da552 100644 --- a/orm/orm_queryset.go +++ b/orm/orm_queryset.go @@ -209,7 +209,6 @@ func (o *querySet) ValuesFlat(result *ParamsList, expr string) (int64, error) { // } func (o *querySet) RowsToMap(result *Params, keyCol, valueCol string) (int64, error) { panic(ErrNotImplement) - return o.orm.alias.DbBaser.RowsTo(o.orm.db, o, o.mi, o.cond, result, keyCol, valueCol, o.orm.alias.TZ) } // query all rows into struct with specify key and value column name. @@ -224,7 +223,6 @@ func (o *querySet) RowsToMap(result *Params, keyCol, valueCol string) (int64, er // } func (o *querySet) RowsToStruct(ptrStruct interface{}, keyCol, valueCol string) (int64, error) { panic(ErrNotImplement) - return o.orm.alias.DbBaser.RowsTo(o.orm.db, o, o.mi, o.cond, ptrStruct, keyCol, valueCol, o.orm.alias.TZ) } // create new QuerySeter. diff --git a/orm/orm_test.go b/orm/orm_test.go index cfdcc1a7..3ae5bc12 100644 --- a/orm/orm_test.go +++ b/orm/orm_test.go @@ -282,10 +282,10 @@ func TestNullDataTypes(t *testing.T) { d = DataNull{ DateTime: time.Now(), - NullString: sql.NullString{"test", true}, - NullBool: sql.NullBool{true, true}, - NullInt64: sql.NullInt64{42, true}, - NullFloat64: sql.NullFloat64{42.42, true}, + NullString: sql.NullString{String: "test", Valid: true}, + NullBool: sql.NullBool{Bool: true, Valid: true}, + NullInt64: sql.NullInt64{Int64: 42, Valid: true}, + NullFloat64: sql.NullFloat64{Float64: 42.42, Valid: true}, } id, err = dORM.Insert(&d) diff --git a/orm/utils.go b/orm/utils.go index 2e347278..26df5a3f 100644 --- a/orm/utils.go +++ b/orm/utils.go @@ -266,5 +266,4 @@ func indirectType(v reflect.Type) reflect.Type { default: return v } - return v } diff --git a/reload.go b/reload.go index 05a24f86..7a43e0ed 100644 --- a/reload.go +++ b/reload.go @@ -29,7 +29,7 @@ type conn struct { net.Conn wg *sync.WaitGroup isclose bool - lock sync.Mutex + lock *sync.Mutex } // Close current processing connection. @@ -102,7 +102,6 @@ func WaitSignal(l net.Listener) error { return nil } } - return nil // It'll never get here. } // Kill current running os process. diff --git a/router.go b/router.go index aa10de2d..fe749ea5 100644 --- a/router.go +++ b/router.go @@ -216,7 +216,6 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface, mappingM if regexErr != nil { //TODO add error handling here to avoid panic panic(regexErr) - return } //now create the Route diff --git a/session/couchbase/sess_couchbase.go b/session/couchbase/sess_couchbase.go index 29661b1a..cab1c2fe 100644 --- a/session/couchbase/sess_couchbase.go +++ b/session/couchbase/sess_couchbase.go @@ -43,7 +43,6 @@ func (cs *CouchbaseSessionStore) Get(key interface{}) interface{} { } else { return nil } - return nil } func (cs *CouchbaseSessionStore) Delete(key interface{}) error { diff --git a/session/mysql/sess_mysql.go b/session/mysql/sess_mysql.go index 2e88aec3..26c0b647 100644 --- a/session/mysql/sess_mysql.go +++ b/session/mysql/sess_mysql.go @@ -47,7 +47,6 @@ func (st *MysqlSessionStore) Get(key interface{}) interface{} { } else { return nil } - return nil } // delete value in mysql session diff --git a/session/postgres/sess_postgresql.go b/session/postgres/sess_postgresql.go index 2838a80d..68030df2 100644 --- a/session/postgres/sess_postgresql.go +++ b/session/postgres/sess_postgresql.go @@ -68,7 +68,6 @@ func (st *PostgresqlSessionStore) Get(key interface{}) interface{} { } else { return nil } - return nil } // delete value in postgresql session diff --git a/session/redis/sess_redis.go b/session/redis/sess_redis.go index 00ef4a63..a1c0e94f 100644 --- a/session/redis/sess_redis.go +++ b/session/redis/sess_redis.go @@ -44,7 +44,6 @@ func (rs *RedisSessionStore) Get(key interface{}) interface{} { } else { return nil } - return nil } // delete value in redis session diff --git a/session/sess_cookie.go b/session/sess_cookie.go index 0fe7b093..67a0802d 100644 --- a/session/sess_cookie.go +++ b/session/sess_cookie.go @@ -36,7 +36,6 @@ func (st *CookieSessionStore) Get(key interface{}) interface{} { } else { return nil } - return nil } // Delete value in cookie session diff --git a/session/sess_file.go b/session/sess_file.go index 6ac22b24..618ba366 100644 --- a/session/sess_file.go +++ b/session/sess_file.go @@ -43,7 +43,6 @@ func (fs *FileSessionStore) Get(key interface{}) interface{} { } else { return nil } - return nil } // Delete value in file session by given key diff --git a/session/sess_mem.go b/session/sess_mem.go index 33c84717..7a2bd0ad 100644 --- a/session/sess_mem.go +++ b/session/sess_mem.go @@ -35,7 +35,6 @@ func (st *MemSessionStore) Get(key interface{}) interface{} { } else { return nil } - return nil } // delete in memory session by key @@ -94,7 +93,6 @@ func (pder *MemProvider) SessionRead(sid string) (SessionStore, error) { pder.lock.Unlock() return newsess, nil } - return nil, nil } // check session store exist in memory session by sid @@ -129,7 +127,6 @@ func (pder *MemProvider) SessionRegenerate(oldsid, sid string) (SessionStore, er pder.lock.Unlock() return newsess, nil } - return nil, nil } // delete session store in memory session by id diff --git a/session/sess_utils.go b/session/sess_utils.go index bea19dba..bfa17a7f 100644 --- a/session/sess_utils.go +++ b/session/sess_utils.go @@ -164,8 +164,6 @@ func decodeCookie(block cipher.Block, hashKey, name, value string, gcmaxlifetime } else { return dst, nil } - // Done. - return nil, nil } // Encoding ------------------------------------------------------------------- diff --git a/toolbox/profile.go b/toolbox/profile.go index 41721b09..ff8710b6 100644 --- a/toolbox/profile.go +++ b/toolbox/profile.go @@ -48,7 +48,7 @@ func ProcessInput(input string, w io.Writer) { // record memory profile in pprof func MemProf() { if f, err := os.Create("mem-" + strconv.Itoa(pid) + ".memprof"); err != nil { - log.Fatal("record memory profile failed: %v", err) + log.Fatal("record memory profile failed: ", err) } else { runtime.GC() pprof.WriteHeapProfile(f) From 6c6e4ecfbc94dc5943fada41de8c398986bdcf1c Mon Sep 17 00:00:00 2001 From: astaxie Date: Sat, 12 Apr 2014 13:18:18 +0800 Subject: [PATCH 10/27] update all files License --- LICENSE | 13 +++++++++++++ admin.go | 6 ++++++ app.go | 6 ++++++ beego.go | 7 ++++++- cache/cache.go | 6 ++++++ cache/cache_test.go | 6 ++++++ cache/conv.go | 6 ++++++ cache/conv_test.go | 6 ++++++ cache/file.go | 11 ++++++----- cache/memcache/memcache.go | 6 ++++++ cache/memory.go | 6 ++++++ cache/redis/redis.go | 6 ++++++ config.go | 6 ++++++ config/config.go | 6 ++++++ config/fake.go | 6 ++++++ config/ini.go | 6 ++++++ config/ini_test.go | 6 ++++++ config/json.go | 6 ++++++ config/json_test.go | 6 ++++++ config/xml/xml.go | 6 ++++++ config/xml/xml_test.go | 6 ++++++ config/yaml/yaml.go | 6 ++++++ config/yaml/yaml_test.go | 6 ++++++ config_test.go | 6 ++++++ context/context.go | 6 ++++++ context/input.go | 6 ++++++ context/input_test.go | 6 ++++++ context/output.go | 6 ++++++ controller.go | 6 ++++++ example/beeapi/controllers/default.go | 7 +++++++ example/beeapi/main.go | 6 ++++++ example/beeapi/models/object.go | 6 ++++++ example/chat/controllers/default.go | 6 ++++++ example/chat/controllers/ws.go | 6 ++++++ example/chat/main.go | 5 +++++ filter.go | 6 ++++++ fiter_test.go | 6 ++++++ flash.go | 6 ++++++ flash_test.go | 6 ++++++ httplib/httplib.go | 6 ++++++ httplib/httplib_test.go | 6 ++++++ log.go | 6 ++++++ logs/conn.go | 6 ++++++ logs/conn_test.go | 6 ++++++ logs/console.go | 6 ++++++ logs/console_test.go | 6 ++++++ logs/file.go | 6 ++++++ logs/file_test.go | 6 ++++++ logs/log.go | 6 ++++++ logs/smtp.go | 6 ++++++ logs/smtp_test.go | 6 ++++++ memzipfile.go | 6 ++++++ middleware/error.go | 6 ++++++ middleware/exceptions.go | 6 ++++++ middleware/i18n.go | 6 ++++++ mime.go | 6 ++++++ orm/cmd.go | 6 ++++++ orm/cmd_utils.go | 6 ++++++ orm/db.go | 6 ++++++ orm/db_alias.go | 6 ++++++ orm/db_mysql.go | 6 ++++++ orm/db_oracle.go | 6 ++++++ orm/db_postgres.go | 6 ++++++ orm/db_sqlite.go | 6 ++++++ orm/db_tables.go | 6 ++++++ orm/db_utils.go | 6 ++++++ orm/models.go | 6 ++++++ orm/models_boot.go | 6 ++++++ orm/models_fields.go | 6 ++++++ orm/models_info_f.go | 6 ++++++ orm/models_info_m.go | 6 ++++++ orm/models_test.go | 6 ++++++ orm/models_utils.go | 6 ++++++ orm/orm.go | 6 ++++++ orm/orm_conds.go | 6 ++++++ orm/orm_log.go | 6 ++++++ orm/orm_object.go | 6 ++++++ orm/orm_querym2m.go | 6 ++++++ orm/orm_queryset.go | 6 ++++++ orm/orm_raw.go | 6 ++++++ orm/orm_test.go | 6 ++++++ orm/types.go | 6 ++++++ orm/utils.go | 6 ++++++ plugins/auth/basic.go | 7 ++++++- reload.go | 6 ++++++ router.go | 6 ++++++ router_test.go | 6 ++++++ session/couchbase/sess_couchbase.go | 6 ++++++ session/mysql/sess_mysql.go | 6 ++++++ session/postgres/sess_postgresql.go | 6 ++++++ session/redis/sess_redis.go | 6 ++++++ session/sess_cookie.go | 6 ++++++ session/sess_cookie_test.go | 6 ++++++ session/sess_file.go | 6 ++++++ session/sess_mem.go | 6 ++++++ session/sess_mem_test.go | 6 ++++++ session/sess_test.go | 6 ++++++ session/sess_utils.go | 6 ++++++ session/session.go | 6 ++++++ staticfile.go | 6 ++++++ template.go | 6 ++++++ template_test.go | 6 ++++++ templatefunc.go | 6 ++++++ templatefunc_test.go | 6 ++++++ testing/client.go | 6 ++++++ toolbox/debug.go | 7 ++++++- toolbox/debug_test.go | 6 ++++++ toolbox/healthcheck.go | 6 ++++++ toolbox/profile.go | 6 ++++++ toolbox/profile_test.go | 6 ++++++ toolbox/statistics.go | 6 ++++++ toolbox/statistics_test.go | 6 ++++++ toolbox/task.go | 6 ++++++ toolbox/task_test.go | 6 ++++++ utils/caller.go | 6 ++++++ utils/caller_test.go | 6 ++++++ utils/captcha/captcha.go | 6 ++++++ utils/captcha/image.go | 7 ++++++- utils/captcha/image_test.go | 6 ++++++ utils/captcha/siprng.go | 7 ++++++- utils/captcha/siprng_test.go | 6 ++++++ utils/file.go | 6 ++++++ utils/file_test.go | 6 ++++++ utils/mail.go | 6 ++++++ utils/mail_test.go | 6 ++++++ utils/rand.go | 6 ++++++ utils/safemap.go | 6 ++++++ utils/safemap_test.go | 6 ++++++ utils/slice.go | 6 ++++++ utils/slice_test.go | 6 ++++++ validation/util.go | 6 ++++++ validation/util_test.go | 6 ++++++ validation/validation.go | 6 ++++++ validation/validation_test.go | 6 ++++++ validation/validators.go | 6 ++++++ 135 files changed, 817 insertions(+), 10 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..5dbd4243 --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ +Copyright 2014 astaxie + +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. \ No newline at end of file diff --git a/admin.go b/admin.go index 3a0d782a..e1dd2743 100644 --- a/admin.go +++ b/admin.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package beego import ( diff --git a/app.go b/app.go index f252367b..d4452edc 100644 --- a/app.go +++ b/app.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package beego import ( diff --git a/beego.go b/beego.go index 32bfe5e4..c09455d5 100644 --- a/beego.go +++ b/beego.go @@ -1,4 +1,9 @@ -// beego is an open-source, high-performance web framework for the Go programming language +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package beego import ( diff --git a/cache/cache.go b/cache/cache.go index 244f9d38..3273e2f9 100644 --- a/cache/cache.go +++ b/cache/cache.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package cache import ( diff --git a/cache/cache_test.go b/cache/cache_test.go index 52612cfd..263ad257 100644 --- a/cache/cache_test.go +++ b/cache/cache_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package cache import ( diff --git a/cache/conv.go b/cache/conv.go index 818dc0c7..00cbdd24 100644 --- a/cache/conv.go +++ b/cache/conv.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package cache import ( diff --git a/cache/conv_test.go b/cache/conv_test.go index 90246282..82d73af7 100644 --- a/cache/conv_test.go +++ b/cache/conv_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package cache import ( diff --git a/cache/file.go b/cache/file.go index d750fecc..7178aa20 100644 --- a/cache/file.go +++ b/cache/file.go @@ -1,8 +1,9 @@ -/** - * package: file - * User: gouki - * Date: 2013-10-22 - 14:22 - */ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package cache import ( diff --git a/cache/memcache/memcache.go b/cache/memcache/memcache.go index bd5ab269..7eea77c8 100644 --- a/cache/memcache/memcache.go +++ b/cache/memcache/memcache.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package cache import ( diff --git a/cache/memory.go b/cache/memory.go index e1284b79..2d2f3803 100644 --- a/cache/memory.go +++ b/cache/memory.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package cache import ( diff --git a/cache/redis/redis.go b/cache/redis/redis.go index 71c7d67e..451166a3 100644 --- a/cache/redis/redis.go +++ b/cache/redis/redis.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package cache import ( diff --git a/config.go b/config.go index 9b722712..2a1589f7 100644 --- a/config.go +++ b/config.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package beego import ( diff --git a/config/config.go b/config/config.go index 5e4c2e9c..7446abb4 100644 --- a/config/config.go +++ b/config/config.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package config import ( diff --git a/config/fake.go b/config/fake.go index 26a9f430..ece4f696 100644 --- a/config/fake.go +++ b/config/fake.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package config import ( diff --git a/config/ini.go b/config/ini.go index 75e6486c..0593864a 100644 --- a/config/ini.go +++ b/config/ini.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package config import ( diff --git a/config/ini_test.go b/config/ini_test.go index 08a69e50..3e792ded 100644 --- a/config/ini_test.go +++ b/config/ini_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package config import ( diff --git a/config/json.go b/config/json.go index 3e3d1d35..a24f9dd6 100644 --- a/config/json.go +++ b/config/json.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package config import ( diff --git a/config/json_test.go b/config/json_test.go index e27f6932..4e83470f 100644 --- a/config/json_test.go +++ b/config/json_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package config import ( diff --git a/config/xml/xml.go b/config/xml/xml.go index 7943d8fe..5028cd45 100644 --- a/config/xml/xml.go +++ b/config/xml/xml.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package config import ( diff --git a/config/xml/xml_test.go b/config/xml/xml_test.go index 1e429e06..49f49ea2 100644 --- a/config/xml/xml_test.go +++ b/config/xml/xml_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package config import ( diff --git a/config/yaml/yaml.go b/config/yaml/yaml.go index bd10b846..65008565 100644 --- a/config/yaml/yaml.go +++ b/config/yaml/yaml.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package config import ( diff --git a/config/yaml/yaml_test.go b/config/yaml/yaml_test.go index 51165e7b..bdcc6d42 100644 --- a/config/yaml/yaml_test.go +++ b/config/yaml/yaml_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package config import ( diff --git a/config_test.go b/config_test.go index d400fd5d..19eaeacf 100644 --- a/config_test.go +++ b/config_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package beego import ( diff --git a/context/context.go b/context/context.go index 36d566b5..87986bec 100644 --- a/context/context.go +++ b/context/context.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package context import ( diff --git a/context/input.go b/context/input.go index 1f093c01..5678b33b 100644 --- a/context/input.go +++ b/context/input.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package context import ( diff --git a/context/input_test.go b/context/input_test.go index 26e95982..f53d013d 100644 --- a/context/input_test.go +++ b/context/input_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package context import ( diff --git a/context/output.go b/context/output.go index 2d7814e4..06b3d717 100644 --- a/context/output.go +++ b/context/output.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package context import ( diff --git a/controller.go b/controller.go index 34b7febd..4dd6709a 100644 --- a/controller.go +++ b/controller.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package beego import ( diff --git a/example/beeapi/controllers/default.go b/example/beeapi/controllers/default.go index 88903b4b..c6e53e74 100644 --- a/example/beeapi/controllers/default.go +++ b/example/beeapi/controllers/default.go @@ -1,7 +1,14 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package controllers import ( "encoding/json" + "github.com/astaxie/beego" "github.com/astaxie/beego/example/beeapi/models" ) diff --git a/example/beeapi/main.go b/example/beeapi/main.go index aef0fb35..bed06196 100644 --- a/example/beeapi/main.go +++ b/example/beeapi/main.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package main import ( diff --git a/example/beeapi/models/object.go b/example/beeapi/models/object.go index 2c72e6b6..46109c50 100644 --- a/example/beeapi/models/object.go +++ b/example/beeapi/models/object.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package models import ( diff --git a/example/chat/controllers/default.go b/example/chat/controllers/default.go index d53bd337..370e6db1 100644 --- a/example/chat/controllers/default.go +++ b/example/chat/controllers/default.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors Unknwon + package controllers import ( diff --git a/example/chat/controllers/ws.go b/example/chat/controllers/ws.go index 9b3f5b10..883bf323 100644 --- a/example/chat/controllers/ws.go +++ b/example/chat/controllers/ws.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors Unknwon + package controllers import ( diff --git a/example/chat/main.go b/example/chat/main.go index 806fe145..be055b25 100644 --- a/example/chat/main.go +++ b/example/chat/main.go @@ -1,3 +1,8 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors Unknwon package main import ( diff --git a/filter.go b/filter.go index 98868865..8fcd8c82 100644 --- a/filter.go +++ b/filter.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package beego import ( diff --git a/fiter_test.go b/fiter_test.go index 7fe9a641..a8573c34 100644 --- a/fiter_test.go +++ b/fiter_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package beego import ( diff --git a/flash.go b/flash.go index 8adb004b..a67ee5c8 100644 --- a/flash.go +++ b/flash.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package beego import ( diff --git a/flash_test.go b/flash_test.go index d329bae4..40eddabb 100644 --- a/flash_test.go +++ b/flash_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package beego import ( diff --git a/httplib/httplib.go b/httplib/httplib.go index d313c603..6dcc1a5e 100644 --- a/httplib/httplib.go +++ b/httplib/httplib.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package httplib import ( diff --git a/httplib/httplib_test.go b/httplib/httplib_test.go index cc56dd88..a0d9d0db 100644 --- a/httplib/httplib_test.go +++ b/httplib/httplib_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package httplib import ( diff --git a/log.go b/log.go index f374085e..ac72ec34 100644 --- a/log.go +++ b/log.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package beego import ( diff --git a/logs/conn.go b/logs/conn.go index eed9ae2f..588e73f4 100644 --- a/logs/conn.go +++ b/logs/conn.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package logs import ( diff --git a/logs/conn_test.go b/logs/conn_test.go index 0d55ddd8..e05cbe05 100644 --- a/logs/conn_test.go +++ b/logs/conn_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package logs import ( diff --git a/logs/console.go b/logs/console.go index 6af6aa16..9316a55e 100644 --- a/logs/console.go +++ b/logs/console.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package logs import ( diff --git a/logs/console_test.go b/logs/console_test.go index 041927ca..a8c942c1 100644 --- a/logs/console_test.go +++ b/logs/console_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package logs import ( diff --git a/logs/file.go b/logs/file.go index 4c560330..f5cbb9ff 100644 --- a/logs/file.go +++ b/logs/file.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package logs import ( diff --git a/logs/file_test.go b/logs/file_test.go index 8f50276d..90349ec6 100644 --- a/logs/file_test.go +++ b/logs/file_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package logs import ( diff --git a/logs/log.go b/logs/log.go index 025da55c..423f9ec3 100644 --- a/logs/log.go +++ b/logs/log.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package logs import ( diff --git a/logs/smtp.go b/logs/smtp.go index 19296887..2b9e50a0 100644 --- a/logs/smtp.go +++ b/logs/smtp.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package logs import ( diff --git a/logs/smtp_test.go b/logs/smtp_test.go index ae4dd019..cb8d3009 100644 --- a/logs/smtp_test.go +++ b/logs/smtp_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package logs import ( diff --git a/memzipfile.go b/memzipfile.go index 50c3205f..92d6003a 100644 --- a/memzipfile.go +++ b/memzipfile.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package beego import ( diff --git a/middleware/error.go b/middleware/error.go index 3f973eb0..3aff9a80 100644 --- a/middleware/error.go +++ b/middleware/error.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package middleware import ( diff --git a/middleware/exceptions.go b/middleware/exceptions.go index b221dfcb..09cb46cb 100644 --- a/middleware/exceptions.go +++ b/middleware/exceptions.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package middleware import "fmt" diff --git a/middleware/i18n.go b/middleware/i18n.go index 973a4a6f..10ec12bb 100644 --- a/middleware/i18n.go +++ b/middleware/i18n.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package middleware //import ( diff --git a/mime.go b/mime.go index 97ed2449..f611a16e 100644 --- a/mime.go +++ b/mime.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package beego import ( diff --git a/orm/cmd.go b/orm/cmd.go index 95be7f4a..ecfc3bd5 100644 --- a/orm/cmd.go +++ b/orm/cmd.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/cmd_utils.go b/orm/cmd_utils.go index 8f6d94db..63cc5a64 100644 --- a/orm/cmd_utils.go +++ b/orm/cmd_utils.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/db.go b/orm/db.go index e84062e8..b67a9bd5 100644 --- a/orm/db.go +++ b/orm/db.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/db_alias.go b/orm/db_alias.go index 6a6623cc..f9d0ab5a 100644 --- a/orm/db_alias.go +++ b/orm/db_alias.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/db_mysql.go b/orm/db_mysql.go index 566f2992..33a01ba4 100644 --- a/orm/db_mysql.go +++ b/orm/db_mysql.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/db_oracle.go b/orm/db_oracle.go index 8e374122..d2253758 100644 --- a/orm/db_oracle.go +++ b/orm/db_oracle.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm // oracle dbBaser diff --git a/orm/db_postgres.go b/orm/db_postgres.go index d26511c0..463150dc 100644 --- a/orm/db_postgres.go +++ b/orm/db_postgres.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/db_sqlite.go b/orm/db_sqlite.go index 81692e2c..94c74a69 100644 --- a/orm/db_sqlite.go +++ b/orm/db_sqlite.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/db_tables.go b/orm/db_tables.go index 854c4214..690b4eaa 100644 --- a/orm/db_tables.go +++ b/orm/db_tables.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/db_utils.go b/orm/db_utils.go index da7c9976..8f963f5e 100644 --- a/orm/db_utils.go +++ b/orm/db_utils.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/models.go b/orm/models.go index 59a8a8a1..ff71ee62 100644 --- a/orm/models.go +++ b/orm/models.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/models_boot.go b/orm/models_boot.go index 03caeb62..0b8db512 100644 --- a/orm/models_boot.go +++ b/orm/models_boot.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/models_fields.go b/orm/models_fields.go index 03d714fc..c1c9b7e2 100644 --- a/orm/models_fields.go +++ b/orm/models_fields.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/models_info_f.go b/orm/models_info_f.go index fadbb335..8ec2bbeb 100644 --- a/orm/models_info_f.go +++ b/orm/models_info_f.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/models_info_m.go b/orm/models_info_m.go index b596fc6a..4f8001b7 100644 --- a/orm/models_info_m.go +++ b/orm/models_info_m.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/models_test.go b/orm/models_test.go index 7f845721..785088be 100644 --- a/orm/models_test.go +++ b/orm/models_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/models_utils.go b/orm/models_utils.go index d8d7cc25..c448c55e 100644 --- a/orm/models_utils.go +++ b/orm/models_utils.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/orm.go b/orm/orm.go index 920d7f40..5503256e 100644 --- a/orm/orm.go +++ b/orm/orm.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/orm_conds.go b/orm/orm_conds.go index 5b1151e2..4b0cfa65 100644 --- a/orm/orm_conds.go +++ b/orm/orm_conds.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/orm_log.go b/orm/orm_log.go index e6df797a..e132992d 100644 --- a/orm/orm_log.go +++ b/orm/orm_log.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/orm_object.go b/orm/orm_object.go index fa644349..44d4aebc 100644 --- a/orm/orm_object.go +++ b/orm/orm_object.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/orm_querym2m.go b/orm/orm_querym2m.go index f0bc94b7..370de60d 100644 --- a/orm/orm_querym2m.go +++ b/orm/orm_querym2m.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/orm_queryset.go b/orm/orm_queryset.go index f21da552..6d2dd418 100644 --- a/orm/orm_queryset.go +++ b/orm/orm_queryset.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/orm_raw.go b/orm/orm_raw.go index a968e347..ea701cce 100644 --- a/orm/orm_raw.go +++ b/orm/orm_raw.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/orm_test.go b/orm/orm_test.go index 3ae5bc12..5859f426 100644 --- a/orm/orm_test.go +++ b/orm/orm_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/types.go b/orm/types.go index 4361c62c..0f1b37ba 100644 --- a/orm/types.go +++ b/orm/types.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/orm/utils.go b/orm/utils.go index 26df5a3f..e53042d9 100644 --- a/orm/utils.go +++ b/orm/utils.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors slene + package orm import ( diff --git a/plugins/auth/basic.go b/plugins/auth/basic.go index 5838acc2..a74bcf22 100644 --- a/plugins/auth/basic.go +++ b/plugins/auth/basic.go @@ -1,4 +1,9 @@ -// basic auth for plugin +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package auth // Example: diff --git a/reload.go b/reload.go index 7a43e0ed..fc4d3f9f 100644 --- a/reload.go +++ b/reload.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package beego import ( diff --git a/router.go b/router.go index fe749ea5..fa88a153 100644 --- a/router.go +++ b/router.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package beego import ( diff --git a/router_test.go b/router_test.go index 2f500835..810177cf 100644 --- a/router_test.go +++ b/router_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package beego import ( diff --git a/session/couchbase/sess_couchbase.go b/session/couchbase/sess_couchbase.go index cab1c2fe..9f68b946 100644 --- a/session/couchbase/sess_couchbase.go +++ b/session/couchbase/sess_couchbase.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package session import ( diff --git a/session/mysql/sess_mysql.go b/session/mysql/sess_mysql.go index 26c0b647..530ca158 100644 --- a/session/mysql/sess_mysql.go +++ b/session/mysql/sess_mysql.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package session // mysql session support need create table as sql: diff --git a/session/postgres/sess_postgresql.go b/session/postgres/sess_postgresql.go index 68030df2..7f905997 100644 --- a/session/postgres/sess_postgresql.go +++ b/session/postgres/sess_postgresql.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package session /* diff --git a/session/redis/sess_redis.go b/session/redis/sess_redis.go index a1c0e94f..3ad19792 100644 --- a/session/redis/sess_redis.go +++ b/session/redis/sess_redis.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package session import ( diff --git a/session/sess_cookie.go b/session/sess_cookie.go index 67a0802d..1a06add6 100644 --- a/session/sess_cookie.go +++ b/session/sess_cookie.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package session import ( diff --git a/session/sess_cookie_test.go b/session/sess_cookie_test.go index 154c15a2..9ab321f5 100644 --- a/session/sess_cookie_test.go +++ b/session/sess_cookie_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package session import ( diff --git a/session/sess_file.go b/session/sess_file.go index 618ba366..74b71223 100644 --- a/session/sess_file.go +++ b/session/sess_file.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package session import ( diff --git a/session/sess_mem.go b/session/sess_mem.go index 7a2bd0ad..e440b2f5 100644 --- a/session/sess_mem.go +++ b/session/sess_mem.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package session import ( diff --git a/session/sess_mem_test.go b/session/sess_mem_test.go index df2a9a1e..5e54c634 100644 --- a/session/sess_mem_test.go +++ b/session/sess_mem_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package session import ( diff --git a/session/sess_test.go b/session/sess_test.go index b903dca6..17947862 100644 --- a/session/sess_test.go +++ b/session/sess_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package session import ( diff --git a/session/sess_utils.go b/session/sess_utils.go index bfa17a7f..a9cce75a 100644 --- a/session/sess_utils.go +++ b/session/sess_utils.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package session import ( diff --git a/session/session.go b/session/session.go index 7da0d41f..3609c10b 100644 --- a/session/session.go +++ b/session/session.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package session import ( diff --git a/staticfile.go b/staticfile.go index e140ed38..c53d17a4 100644 --- a/staticfile.go +++ b/staticfile.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package beego import ( diff --git a/template.go b/template.go index eb8d0c5d..95deb443 100644 --- a/template.go +++ b/template.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package beego //@todo add template funcs diff --git a/template_test.go b/template_test.go index 8da15d0e..15014980 100644 --- a/template_test.go +++ b/template_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package beego import ( diff --git a/templatefunc.go b/templatefunc.go index 1eb40c0f..c7bd9238 100644 --- a/templatefunc.go +++ b/templatefunc.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package beego import ( diff --git a/templatefunc_test.go b/templatefunc_test.go index 726ce2d2..aa1ba1ed 100644 --- a/templatefunc_test.go +++ b/templatefunc_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package beego import ( diff --git a/testing/client.go b/testing/client.go index 28ad9a7d..a4408681 100644 --- a/testing/client.go +++ b/testing/client.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package testing import ( diff --git a/toolbox/debug.go b/toolbox/debug.go index 86638d05..dd775e69 100644 --- a/toolbox/debug.go +++ b/toolbox/debug.go @@ -1,4 +1,9 @@ -// Here are the features: healthcheck, profile, statistics and task. +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package toolbox import ( diff --git a/toolbox/debug_test.go b/toolbox/debug_test.go index d72b8b7b..4ef89983 100644 --- a/toolbox/debug_test.go +++ b/toolbox/debug_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package toolbox import ( diff --git a/toolbox/healthcheck.go b/toolbox/healthcheck.go index 1540c7c7..0f4c0e29 100644 --- a/toolbox/healthcheck.go +++ b/toolbox/healthcheck.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package toolbox //type DatabaseCheck struct { diff --git a/toolbox/profile.go b/toolbox/profile.go index ff8710b6..3200d547 100644 --- a/toolbox/profile.go +++ b/toolbox/profile.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package toolbox import ( diff --git a/toolbox/profile_test.go b/toolbox/profile_test.go index ea1135a7..661d6ea1 100644 --- a/toolbox/profile_test.go +++ b/toolbox/profile_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package toolbox import ( diff --git a/toolbox/statistics.go b/toolbox/statistics.go index 6042197e..8904dc60 100644 --- a/toolbox/statistics.go +++ b/toolbox/statistics.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package toolbox import ( diff --git a/toolbox/statistics_test.go b/toolbox/statistics_test.go index ca4bffff..ec7ceab5 100644 --- a/toolbox/statistics_test.go +++ b/toolbox/statistics_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package toolbox import ( diff --git a/toolbox/task.go b/toolbox/task.go index b5558c15..dadc8913 100644 --- a/toolbox/task.go +++ b/toolbox/task.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package toolbox import ( diff --git a/toolbox/task_test.go b/toolbox/task_test.go index d61a2595..2bbd4ac7 100644 --- a/toolbox/task_test.go +++ b/toolbox/task_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package toolbox import ( diff --git a/utils/caller.go b/utils/caller.go index 5cf45ed9..52cd5fe4 100644 --- a/utils/caller.go +++ b/utils/caller.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package utils import ( diff --git a/utils/caller_test.go b/utils/caller_test.go index 1a7e9c75..c7068f3c 100644 --- a/utils/caller_test.go +++ b/utils/caller_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package utils import ( diff --git a/utils/captcha/captcha.go b/utils/captcha/captcha.go index f3998733..f12634d5 100644 --- a/utils/captcha/captcha.go +++ b/utils/captcha/captcha.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + // an example for use captcha // // ``` diff --git a/utils/captcha/image.go b/utils/captcha/image.go index 31c66a36..93eb3383 100644 --- a/utils/captcha/image.go +++ b/utils/captcha/image.go @@ -1,4 +1,9 @@ -// modifiy and integrated to Beego from https://github.com/dchest/captcha +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package captcha import ( diff --git a/utils/captcha/image_test.go b/utils/captcha/image_test.go index e80cc42c..14a18fbc 100644 --- a/utils/captcha/image_test.go +++ b/utils/captcha/image_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package captcha import ( diff --git a/utils/captcha/siprng.go b/utils/captcha/siprng.go index 6f9274d8..26651b9b 100644 --- a/utils/captcha/siprng.go +++ b/utils/captcha/siprng.go @@ -1,4 +1,9 @@ -// modifiy and integrated to Beego from https://github.com/dchest/captcha +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package captcha import ( diff --git a/utils/captcha/siprng_test.go b/utils/captcha/siprng_test.go index 2fb81f7e..8f3444b4 100644 --- a/utils/captcha/siprng_test.go +++ b/utils/captcha/siprng_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package captcha import "testing" diff --git a/utils/file.go b/utils/file.go index c0137cb5..0f08045b 100644 --- a/utils/file.go +++ b/utils/file.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package utils import ( diff --git a/utils/file_test.go b/utils/file_test.go index c183484b..8dfd1ff6 100644 --- a/utils/file_test.go +++ b/utils/file_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package utils import ( diff --git a/utils/mail.go b/utils/mail.go index 828b790c..8eb97b1a 100644 --- a/utils/mail.go +++ b/utils/mail.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package utils import ( diff --git a/utils/mail_test.go b/utils/mail_test.go index c0535ed5..109bf7ba 100644 --- a/utils/mail_test.go +++ b/utils/mail_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package utils import "testing" diff --git a/utils/rand.go b/utils/rand.go index 482c7059..d9629e60 100644 --- a/utils/rand.go +++ b/utils/rand.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package utils import ( diff --git a/utils/safemap.go b/utils/safemap.go index 30ccceff..35bf695b 100644 --- a/utils/safemap.go +++ b/utils/safemap.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package utils import ( diff --git a/utils/safemap_test.go b/utils/safemap_test.go index 8e4eab48..e1148a1c 100644 --- a/utils/safemap_test.go +++ b/utils/safemap_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package utils import ( diff --git a/utils/slice.go b/utils/slice.go index fd3d5166..fee1b741 100644 --- a/utils/slice.go +++ b/utils/slice.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package utils import ( diff --git a/utils/slice_test.go b/utils/slice_test.go index d06a94a6..fb2266a0 100644 --- a/utils/slice_test.go +++ b/utils/slice_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package utils import ( diff --git a/validation/util.go b/validation/util.go index a157742d..3ac56f81 100644 --- a/validation/util.go +++ b/validation/util.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package validation import ( diff --git a/validation/util_test.go b/validation/util_test.go index e33025c2..8345daa6 100644 --- a/validation/util_test.go +++ b/validation/util_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package validation import ( diff --git a/validation/validation.go b/validation/validation.go index a22e8bff..7087ccff 100644 --- a/validation/validation.go +++ b/validation/validation.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package validation import ( diff --git a/validation/validation_test.go b/validation/validation_test.go index de9aa21a..47de304a 100644 --- a/validation/validation_test.go +++ b/validation/validation_test.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package validation import ( diff --git a/validation/validators.go b/validation/validators.go index 631e0f38..d59b42b0 100644 --- a/validation/validators.go +++ b/validation/validators.go @@ -1,3 +1,9 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + package validation import ( From f9b8617fa338e30fe2c4304cfa8ac8a766f57444 Mon Sep 17 00:00:00 2001 From: astaxie Date: Tue, 15 Apr 2014 05:02:50 +0800 Subject: [PATCH 11/27] context: fix multipart/form-data --- context/input.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/context/input.go b/context/input.go index 5678b33b..8d9b76e6 100644 --- a/context/input.go +++ b/context/input.go @@ -274,19 +274,13 @@ func (input *BeegoInput) SetData(key, val interface{}) { // parseForm or parseMultiForm based on Content-type func (input *BeegoInput) ParseFormOrMulitForm(maxMemory int64) error { // Parse the body depending on the content type. - switch input.Header("Content-Type") { - case "application/x-www-form-urlencoded": - // Typical form. - if err := input.Request.ParseForm(); err != nil { - return errors.New("Error parsing request body:" + err.Error()) - } - - case "multipart/form-data": + if strings.Contains(input.Header("Content-Type"), "multipart/form-data") { if err := input.Request.ParseMultipartForm(maxMemory); err != nil { return errors.New("Error parsing request body:" + err.Error()) } + } else if err := input.Request.ParseForm(); err != nil { + return errors.New("Error parsing request body:" + err.Error()) } - return nil } From b2bd829d39d4ae67f9b64453ad5072afa7bc9de0 Mon Sep 17 00:00:00 2001 From: astaxie Date: Tue, 15 Apr 2014 05:03:20 +0800 Subject: [PATCH 12/27] beego: add link in the admin console --- admin.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/admin.go b/admin.go index e1dd2743..ffaed11e 100644 --- a/admin.go +++ b/admin.go @@ -55,12 +55,12 @@ func init() { func adminIndex(rw http.ResponseWriter, r *http.Request) { rw.Write([]byte("Welcome to Admin Dashboard\n")) rw.Write([]byte("There are servral functions:\n")) - rw.Write([]byte("1. Record all request and request time, http://localhost:8088/qps\n")) - rw.Write([]byte("2. Get runtime profiling data by the pprof, http://localhost:8088/prof\n")) - rw.Write([]byte("3. Get healthcheck result from http://localhost:8088/healthcheck\n")) - rw.Write([]byte("4. Get current task infomation from taskhttp://localhost:8088/task \n")) - rw.Write([]byte("5. To run a task passed a param http://localhost:8088/runtask\n")) - rw.Write([]byte("6. Get all confige & router infomation http://localhost:8088/listconf\n")) + rw.Write([]byte("1. Record all request and request time, http://localhost:8088/qps\n")) + rw.Write([]byte("2. Get runtime profiling data by the pprof, http://localhost:8088/prof\n")) + rw.Write([]byte("3. Get healthcheck result from http://localhost:8088/healthcheck\n")) + rw.Write([]byte("4. Get current task infomation from task http://localhost:8088/task \n")) + rw.Write([]byte("5. To run a task passed a param http://localhost:8088/runtask\n")) + rw.Write([]byte("6. Get all confige & router infomation http://localhost:8088/listconf\n")) } From b2a69f505c934c46eff2f0964c451976be82809e Mon Sep 17 00:00:00 2001 From: astaxie Date: Mon, 28 Apr 2014 18:07:30 +0800 Subject: [PATCH 13/27] beego: support other analisys & fix typo --- context/input.go | 2 +- fiter_test.go => filter_test.go | 0 router.go | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename fiter_test.go => filter_test.go (100%) diff --git a/context/input.go b/context/input.go index 8d9b76e6..c405b27e 100644 --- a/context/input.go +++ b/context/input.go @@ -152,7 +152,7 @@ func (input *BeegoInput) IsWebsocket() bool { // IsSecure returns boolean of whether file uploads in this request or not.. func (input *BeegoInput) IsUpload() bool { - return input.Header("Content-Type") == "multipart/form-data" + return strings.Contains(input.Header("Content-Type"), "multipart/form-data") } // IP returns request client ip. diff --git a/fiter_test.go b/filter_test.go similarity index 100% rename from fiter_test.go rename to filter_test.go diff --git a/router.go b/router.go index fa88a153..44963cbf 100644 --- a/router.go +++ b/router.go @@ -556,7 +556,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) goto Admin } - if context.Input.IsPost() { + if !context.Input.IsGet() && !context.Input.IsHead() { if CopyRequestBody && !context.Input.IsUpload() { context.Input.CopyBody() } From 46641ef3b63059dcbc57c5e28c442be5030bc903 Mon Sep 17 00:00:00 2001 From: astaxie Date: Thu, 8 May 2014 10:51:29 +0800 Subject: [PATCH 14/27] fix the typo --- controller.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/controller.go b/controller.go index 4dd6709a..13acbbff 100644 --- a/controller.go +++ b/controller.go @@ -46,7 +46,7 @@ type Controller struct { CruSession session.SessionStore XSRFExpire int AppController interface{} - EnableReander bool + EnableRender bool } // ControllerInterface is an interface to uniform all controller handler. @@ -75,7 +75,7 @@ func (c *Controller) Init(ctx *context.Context, controllerName, actionName strin c.Ctx = ctx c.TplExt = "tpl" c.AppController = app - c.EnableReander = true + c.EnableRender = true c.Data = ctx.Input.Data } @@ -126,7 +126,7 @@ func (c *Controller) Options() { // Render sends the response with rendered template bytes as text/html type. func (c *Controller) Render() error { - if !c.EnableReander { + if !c.EnableRender { return nil } rb, err := c.RenderBytes() From d5d5f23756befd02a5d3ad0f4fdb24ec1e763c22 Mon Sep 17 00:00:00 2001 From: astaxie Date: Thu, 8 May 2014 16:58:08 +0800 Subject: [PATCH 15/27] httplib:support file upload --- httplib/README.md | 13 +++++++++++ httplib/httplib.go | 50 +++++++++++++++++++++++++++++++++++------ httplib/httplib_test.go | 13 +++++++++++ 3 files changed, 69 insertions(+), 7 deletions(-) diff --git a/httplib/README.md b/httplib/README.md index 95a10d86..eaf1d506 100644 --- a/httplib/README.md +++ b/httplib/README.md @@ -60,3 +60,16 @@ some http request need setcookie. So set it like this: cookie.Value = "astaxie" httplib.Get("http://beego.me/").SetCookie(cookie) +## upload file +httplib support mutil file upload, use `b.PostFile()` + + b:=httplib.Post("http://beego.me/") + b.Param("username","astaxie") + b.Param("password","123456") + b.PostFile("uploadfile1", "httplib.pdf") + b.PostFile("uploadfile2", "httplib.txt") + str, err := b.String() + if err != nil { + t.Fatal(err) + } + fmt.Println(str) diff --git a/httplib/httplib.go b/httplib/httplib.go index 6dcc1a5e..e7736308 100644 --- a/httplib/httplib.go +++ b/httplib/httplib.go @@ -13,6 +13,7 @@ import ( "encoding/xml" "io" "io/ioutil" + "mime/multipart" "net" "net/http" "net/http/httputil" @@ -30,7 +31,7 @@ func Get(url string) *BeegoHttpRequest { req.Method = "GET" req.Header = http.Header{} req.Header.Set("User-Agent", defaultUserAgent) - return &BeegoHttpRequest{url, &req, map[string]string{}, false, 60 * time.Second, 60 * time.Second, nil, nil, nil} + return &BeegoHttpRequest{url, &req, map[string]string{}, map[string]string{}, false, 60 * time.Second, 60 * time.Second, nil, nil, nil} } // Post returns *BeegoHttpRequest with POST method. @@ -39,7 +40,7 @@ func Post(url string) *BeegoHttpRequest { req.Method = "POST" req.Header = http.Header{} req.Header.Set("User-Agent", defaultUserAgent) - return &BeegoHttpRequest{url, &req, map[string]string{}, false, 60 * time.Second, 60 * time.Second, nil, nil, nil} + return &BeegoHttpRequest{url, &req, map[string]string{}, map[string]string{}, false, 60 * time.Second, 60 * time.Second, nil, nil, nil} } // Put returns *BeegoHttpRequest with PUT method. @@ -48,7 +49,7 @@ func Put(url string) *BeegoHttpRequest { req.Method = "PUT" req.Header = http.Header{} req.Header.Set("User-Agent", defaultUserAgent) - return &BeegoHttpRequest{url, &req, map[string]string{}, false, 60 * time.Second, 60 * time.Second, nil, nil, nil} + return &BeegoHttpRequest{url, &req, map[string]string{}, map[string]string{}, false, 60 * time.Second, 60 * time.Second, nil, nil, nil} } // Delete returns *BeegoHttpRequest DELETE GET method. @@ -57,7 +58,7 @@ func Delete(url string) *BeegoHttpRequest { req.Method = "DELETE" req.Header = http.Header{} req.Header.Set("User-Agent", defaultUserAgent) - return &BeegoHttpRequest{url, &req, map[string]string{}, false, 60 * time.Second, 60 * time.Second, nil, nil, nil} + return &BeegoHttpRequest{url, &req, map[string]string{}, map[string]string{}, false, 60 * time.Second, 60 * time.Second, nil, nil, nil} } // Head returns *BeegoHttpRequest with HEAD method. @@ -66,7 +67,7 @@ func Head(url string) *BeegoHttpRequest { req.Method = "HEAD" req.Header = http.Header{} req.Header.Set("User-Agent", defaultUserAgent) - return &BeegoHttpRequest{url, &req, map[string]string{}, false, 60 * time.Second, 60 * time.Second, nil, nil, nil} + return &BeegoHttpRequest{url, &req, map[string]string{}, map[string]string{}, false, 60 * time.Second, 60 * time.Second, nil, nil, nil} } // BeegoHttpRequest provides more useful methods for requesting one url than http.Request. @@ -74,6 +75,7 @@ type BeegoHttpRequest struct { url string req *http.Request params map[string]string + files map[string]string showdebug bool connectTimeout time.Duration readWriteTimeout time.Duration @@ -138,6 +140,11 @@ func (b *BeegoHttpRequest) Param(key, value string) *BeegoHttpRequest { return b } +func (b *BeegoHttpRequest) PostFile(formname, filename string) *BeegoHttpRequest { + b.files[formname] = filename + return b +} + // Body adds request raw body. // it supports string and []byte. func (b *BeegoHttpRequest) Body(data interface{}) *BeegoHttpRequest { @@ -175,8 +182,37 @@ func (b *BeegoHttpRequest) getResponse() (*http.Response, error) { b.url = b.url + "?" + paramBody } } else if b.req.Method == "POST" && b.req.Body == nil && len(paramBody) > 0 { - b.Header("Content-Type", "application/x-www-form-urlencoded") - b.Body(paramBody) + if len(b.files) > 0 { + bodyBuf := &bytes.Buffer{} + bodyWriter := multipart.NewWriter(bodyBuf) + for formname, filename := range b.files { + fileWriter, err := bodyWriter.CreateFormFile(formname, filename) + if err != nil { + return nil, err + } + fh, err := os.Open(filename) + if err != nil { + return nil, err + } + //iocopy + _, err = io.Copy(fileWriter, fh) + fh.Close() + if err != nil { + return nil, err + } + } + for k, v := range b.params { + bodyWriter.WriteField(k, v) + } + contentType := bodyWriter.FormDataContentType() + bodyWriter.Close() + b.Header("Content-Type", contentType) + b.req.Body = ioutil.NopCloser(bodyBuf) + b.req.ContentLength = int64(bodyBuf.Len()) + } else { + b.Header("Content-Type", "application/x-www-form-urlencoded") + b.Body(paramBody) + } } url, err := url.Parse(b.url) diff --git a/httplib/httplib_test.go b/httplib/httplib_test.go index a0d9d0db..4689910a 100644 --- a/httplib/httplib_test.go +++ b/httplib/httplib_test.go @@ -7,6 +7,7 @@ package httplib import ( + "fmt" "io/ioutil" "testing" ) @@ -36,3 +37,15 @@ func TestGetUrl(t *testing.T) { t.Fatal("has no info") } } + +func TestPost(t *testing.T) { + b := Post("http://beego.me/").Debug(true) + b.Param("username", "astaxie") + b.Param("password", "hello") + b.PostFile("uploadfile", "httplib.go") + str, err := b.String() + if err != nil { + t.Fatal(err) + } + fmt.Println(str) +} From 3caf1896d6697df3f1a2374de549d0c187938a30 Mon Sep 17 00:00:00 2001 From: "toby.zxj" Date: Fri, 9 May 2014 15:48:50 +0800 Subject: [PATCH 16/27] httplib support to set the protocol version for incoming requests --- httplib/README.md | 5 +++++ httplib/httplib.go | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/httplib/README.md b/httplib/README.md index eaf1d506..6ec592ab 100644 --- a/httplib/README.md +++ b/httplib/README.md @@ -73,3 +73,8 @@ httplib support mutil file upload, use `b.PostFile()` t.Fatal(err) } fmt.Println(str) + +## set HTTP version +some servers need to specify the protocol version of HTTP + + httplib.Get("http://beego.me/").SetProtocolVersion("HTTP/1.1") \ No newline at end of file diff --git a/httplib/httplib.go b/httplib/httplib.go index e7736308..18995283 100644 --- a/httplib/httplib.go +++ b/httplib/httplib.go @@ -109,6 +109,23 @@ func (b *BeegoHttpRequest) Header(key, value string) *BeegoHttpRequest { return b } +// Set the protocol version for incoming requests. +// Client requests always use HTTP/1.1. +func (b *BeegoHttpRequest) SetProtocolVersion(vers string) *BeegoHttpRequest { + if len(vers) == 0 { + vers = "HTTP/1.1" + } + + major, minor, ok := http.ParseHTTPVersion(vers) + if ok { + b.req.Proto = vers + b.req.ProtoMajor = major + b.req.ProtoMinor = minor + } + + return b +} + // SetCookie add cookie into request. func (b *BeegoHttpRequest) SetCookie(cookie *http.Cookie) *BeegoHttpRequest { b.req.Header.Add("Cookie", cookie.String()) From 74c309cefdc48fabbe1829067377d48d6c8d180e Mon Sep 17 00:00:00 2001 From: jessonchan Date: Wed, 14 May 2014 20:08:51 +0800 Subject: [PATCH 17/27] refator func --- orm/models_boot.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/orm/models_boot.go b/orm/models_boot.go index 0b8db512..16423755 100644 --- a/orm/models_boot.go +++ b/orm/models_boot.go @@ -16,7 +16,7 @@ import ( // register models. // prefix means table name prefix. -func registerModel(model interface{}, prefix string) { +func registerModel(prefix string, model interface{}) { val := reflect.ValueOf(model) ind := reflect.Indirect(val) typ := ind.Type() @@ -292,23 +292,17 @@ end: // register models func RegisterModel(models ...interface{}) { - if modelCache.done { - panic(fmt.Errorf("RegisterModel must be run before BootStrap")) - } - - for _, model := range models { - registerModel(model, "") - } + RegisterModelWithPrefix("", models) } -// register model with a prefix +// register models with a prefix func RegisterModelWithPrefix(prefix string, models ...interface{}) { if modelCache.done { panic(fmt.Errorf("RegisterModel must be run before BootStrap")) } for _, model := range models { - registerModel(model, prefix) + registerModel(prefix, model) } } From 6f78f1d4b261cf0e9d18a0f06302e2eb20e90aef Mon Sep 17 00:00:00 2001 From: jessonchan Date: Thu, 15 May 2014 11:34:44 +0800 Subject: [PATCH 18/27] bug fixed --- orm/models_boot.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orm/models_boot.go b/orm/models_boot.go index 16423755..0abaf98f 100644 --- a/orm/models_boot.go +++ b/orm/models_boot.go @@ -292,7 +292,7 @@ end: // register models func RegisterModel(models ...interface{}) { - RegisterModelWithPrefix("", models) + RegisterModelWithPrefix("", models...) } // register models with a prefix From 10d2c7c328b5d85c726e5788c7a3f3d55803d452 Mon Sep 17 00:00:00 2001 From: astaxie Date: Thu, 15 May 2014 14:18:47 +0800 Subject: [PATCH 19/27] config: fix the import issue --- config/xml/xml.go | 5 +++-- config/xml/xml_test.go | 4 +++- config/yaml/yaml.go | 5 +++-- config/yaml/yaml_test.go | 4 +++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/config/xml/xml.go b/config/xml/xml.go index 5028cd45..f763d4f0 100644 --- a/config/xml/xml.go +++ b/config/xml/xml.go @@ -14,6 +14,7 @@ import ( "strings" "sync" + "github.com/astaxie/beego/config" "github.com/beego/x2j" ) @@ -24,7 +25,7 @@ type XMLConfig struct { } // Parse returns a ConfigContainer with parsed xml config map. -func (xmls *XMLConfig) Parse(filename string) (ConfigContainer, error) { +func (xmls *XMLConfig) Parse(filename string) (config.ConfigContainer, error) { file, err := os.Open(filename) if err != nil { return nil, err @@ -101,5 +102,5 @@ func (c *XMLConfigContainer) DIY(key string) (v interface{}, err error) { } func init() { - Register("xml", &XMLConfig{}) + config.Register("xml", &XMLConfig{}) } diff --git a/config/xml/xml_test.go b/config/xml/xml_test.go index 49f49ea2..767b02ed 100644 --- a/config/xml/xml_test.go +++ b/config/xml/xml_test.go @@ -9,6 +9,8 @@ package config import ( "os" "testing" + + "github.com/astaxie/beego/config" ) //xml parse should incluce in tags @@ -36,7 +38,7 @@ func TestXML(t *testing.T) { } f.Close() defer os.Remove("testxml.conf") - xmlconf, err := NewConfig("xml", "testxml.conf") + xmlconf, err := config.NewConfig("xml", "testxml.conf") if err != nil { t.Fatal(err) } diff --git a/config/yaml/yaml.go b/config/yaml/yaml.go index 65008565..04a6def3 100644 --- a/config/yaml/yaml.go +++ b/config/yaml/yaml.go @@ -16,6 +16,7 @@ import ( "strings" "sync" + "github.com/astaxie/beego/config" "github.com/beego/goyaml2" ) @@ -24,7 +25,7 @@ type YAMLConfig struct { } // Parse returns a ConfigContainer with parsed yaml config map. -func (yaml *YAMLConfig) Parse(filename string) (ConfigContainer, error) { +func (yaml *YAMLConfig) Parse(filename string) (config.ConfigContainer, error) { y := &YAMLConfigContainer{ data: make(map[string]interface{}), } @@ -146,5 +147,5 @@ func (c *YAMLConfigContainer) DIY(key string) (v interface{}, err error) { } func init() { - Register("yaml", &YAMLConfig{}) + config.Register("yaml", &YAMLConfig{}) } diff --git a/config/yaml/yaml_test.go b/config/yaml/yaml_test.go index bdcc6d42..fbeaf654 100644 --- a/config/yaml/yaml_test.go +++ b/config/yaml/yaml_test.go @@ -9,6 +9,8 @@ package config import ( "os" "testing" + + "github.com/astaxie/beego/config" ) var yamlcontext = ` @@ -33,7 +35,7 @@ func TestYaml(t *testing.T) { } f.Close() defer os.Remove("testyaml.conf") - yamlconf, err := NewConfig("yaml", "testyaml.conf") + yamlconf, err := config.NewConfig("yaml", "testyaml.conf") if err != nil { t.Fatal(err) } From 2629de28f2633707711e9976a595fda383c773e2 Mon Sep 17 00:00:00 2001 From: astaxie Date: Fri, 16 May 2014 10:18:15 +0800 Subject: [PATCH 20/27] beego: support more router //design model beego.Get(router, beego.FilterFunc) beego.Post(router, beego.FilterFunc) beego.Put(router, beego.FilterFunc) beego.Head(router, beego.FilterFunc) beego.Options(router, beego.FilterFunc) beego.Delete(router, beego.FilterFunc) beego.Handler(router, http.Handler) //example beego.Get("/user", func(ctx *context.Context) { ctx.Output.Body([]byte("Get userlist")) }) beego.Post("/user", func(ctx *context.Context) { ctx.Output.Body([]byte("add userlist")) }) beego.Delete("/user/:id", func(ctx *context.Context) { ctx.Output.Body([]byte([]byte(ctx.Input.Param(":id"))) }) import ( "http" "github.com/gorilla/rpc" "github.com/gorilla/rpc/json" ) func init() { s := rpc.NewServer() s.RegisterCodec(json.NewCodec(), "application/json") s.RegisterService(new(HelloService), "") beego.Handler("/rpc", s) } --- app.go | 54 +++++++ beego.go | 54 +++++++ router.go | 393 +++++++++++++++++++++++++++++++++++-------------- router_test.go | 46 ++++++ 4 files changed, 438 insertions(+), 109 deletions(-) diff --git a/app.go b/app.go index d4452edc..3344d1a5 100644 --- a/app.go +++ b/app.go @@ -132,6 +132,60 @@ func (app *App) AutoRouterWithPrefix(prefix string, c ControllerInterface) *App return app } +// add router for Get method +func (app *App) Get(rootpath string, f FilterFunc) *App { + app.Handlers.Get(rootpath, f) + return app +} + +// add router for Post method +func (app *App) Post(rootpath string, f FilterFunc) *App { + app.Handlers.Post(rootpath, f) + return app +} + +// add router for Put method +func (app *App) Put(rootpath string, f FilterFunc) *App { + app.Handlers.Put(rootpath, f) + return app +} + +// add router for Delete method +func (app *App) Delete(rootpath string, f FilterFunc) *App { + app.Handlers.Delete(rootpath, f) + return app +} + +// add router for Options method +func (app *App) Options(rootpath string, f FilterFunc) *App { + app.Handlers.Options(rootpath, f) + return app +} + +// add router for Head method +func (app *App) Head(rootpath string, f FilterFunc) *App { + app.Handlers.Head(rootpath, f) + return app +} + +// add router for Patch method +func (app *App) Patch(rootpath string, f FilterFunc) *App { + app.Handlers.Patch(rootpath, f) + return app +} + +// add router for Patch method +func (app *App) Any(rootpath string, f FilterFunc) *App { + app.Handlers.Any(rootpath, f) + return app +} + +// add router for http.Handler +func (app *App) Handler(rootpath string, h http.Handler) *App { + app.Handlers.Handler(rootpath, h) + return app +} + // UrlFor creates a url with another registered controller handler with params. // The endpoint is formed as path.controller.name to defined the controller method which will run. // The values need key-pair data to assign into controller method. diff --git a/beego.go b/beego.go index c09455d5..3631a7c6 100644 --- a/beego.go +++ b/beego.go @@ -121,6 +121,60 @@ func AutoPrefix(prefix string, c ControllerInterface) *App { return BeeApp } +// register router for Get method +func Get(rootpath string, f FilterFunc) *App { + BeeApp.Get(rootpath, f) + return BeeApp +} + +// register router for Post method +func Post(rootpath string, f FilterFunc) *App { + BeeApp.Post(rootpath, f) + return BeeApp +} + +// register router for Delete method +func Delete(rootpath string, f FilterFunc) *App { + BeeApp.Delete(rootpath, f) + return BeeApp +} + +// register router for Put method +func Put(rootpath string, f FilterFunc) *App { + BeeApp.Put(rootpath, f) + return BeeApp +} + +// register router for Head method +func Head(rootpath string, f FilterFunc) *App { + BeeApp.Head(rootpath, f) + return BeeApp +} + +// register router for Options method +func Options(rootpath string, f FilterFunc) *App { + BeeApp.Options(rootpath, f) + return BeeApp +} + +// register router for Patch method +func Patch(rootpath string, f FilterFunc) *App { + BeeApp.Patch(rootpath, f) + return BeeApp +} + +// register router for all method +func Any(rootpath string, f FilterFunc) *App { + BeeApp.Any(rootpath, f) + return BeeApp +} + +// register router for own Handler +func Handler(rootpath string, h http.Handler) *App { + BeeApp.Handler(rootpath, h) + return BeeApp +} + // ErrorHandler registers http.HandlerFunc to each http err code string. // usage: // beego.ErrorHandler("404",NotFound) diff --git a/router.go b/router.go index 44963cbf..557bdc8b 100644 --- a/router.go +++ b/router.go @@ -35,6 +35,12 @@ const ( FinishRouter ) +const ( + routerTypeBeego = iota + routerTypeRESTFul + routerTypeHandler +) + var ( // supported http methods. HTTPMETHOD = []string{"get", "post", "put", "delete", "patch", "options", "head", "trace", "connect"} @@ -60,6 +66,9 @@ type controllerInfo struct { controllerType reflect.Type methods map[string]string hasMethod bool + handler http.Handler + runfunction FilterFunc + routerType int } // ControllerRegistor containers registered router rules, controller handlers and filters. @@ -92,10 +101,211 @@ func NewControllerRegistor() *ControllerRegistor { // Add("/api",&RestController{},"get,post:ApiFunc") // Add("/simple",&SimpleController{},"get:GetFunc;post:PostFunc") func (p *ControllerRegistor) Add(pattern string, c ControllerInterface, mappingMethods ...string) { - parts := strings.Split(pattern, "/") + j, params, parts := p.splitRoute(pattern) + reflectVal := reflect.ValueOf(c) + t := reflect.Indirect(reflectVal).Type() + methods := make(map[string]string) + if len(mappingMethods) > 0 { + semi := strings.Split(mappingMethods[0], ";") + for _, v := range semi { + colon := strings.Split(v, ":") + if len(colon) != 2 { + panic("method mapping format is invalid") + } + comma := strings.Split(colon[0], ",") + for _, m := range comma { + if m == "*" || utils.InSlice(strings.ToLower(m), HTTPMETHOD) { + if val := reflectVal.MethodByName(colon[1]); val.IsValid() { + methods[strings.ToLower(m)] = colon[1] + } else { + panic(colon[1] + " method doesn't exist in the controller " + t.Name()) + } + } else { + panic(v + " is an invalid method mapping. Method doesn't exist " + m) + } + } + } + } + if j == 0 { + //now create the Route + route := &controllerInfo{} + route.pattern = pattern + route.controllerType = t + route.methods = methods + route.routerType = routerTypeBeego + if len(methods) > 0 { + route.hasMethod = true + } + p.fixrouters = append(p.fixrouters, route) + } else { // add regexp routers + //recreate the url pattern, with parameters replaced + //by regular expressions. then compile the regex + pattern = strings.Join(parts, "/") + regex, regexErr := regexp.Compile(pattern) + if regexErr != nil { + //TODO add error handling here to avoid panic + panic(regexErr) + } + //now create the Route + + route := &controllerInfo{} + route.regex = regex + route.params = params + route.pattern = pattern + route.methods = methods + route.routerType = routerTypeBeego + if len(methods) > 0 { + route.hasMethod = true + } + route.controllerType = t + p.routers = append(p.routers, route) + } +} + +// add get method +// usage: +// Get("/", func(ctx *context.Context){ +// ctx.Output.Body("hello world") +// }) +func (p *ControllerRegistor) Get(pattern string, f FilterFunc) { + p.AddMethod("get", pattern, f) +} + +// add post method +// usage: +// Post("/api", func(ctx *context.Context){ +// ctx.Output.Body("hello world") +// }) +func (p *ControllerRegistor) Post(pattern string, f FilterFunc) { + p.AddMethod("post", pattern, f) +} + +// add put method +// usage: +// Put("/api/:id", func(ctx *context.Context){ +// ctx.Output.Body("hello world") +// }) +func (p *ControllerRegistor) Put(pattern string, f FilterFunc) { + p.AddMethod("put", pattern, f) +} + +// add delete method +// usage: +// Delete("/api/:id", func(ctx *context.Context){ +// ctx.Output.Body("hello world") +// }) +func (p *ControllerRegistor) Delete(pattern string, f FilterFunc) { + p.AddMethod("delete", pattern, f) +} + +// add head method +// usage: +// Head("/api/:id", func(ctx *context.Context){ +// ctx.Output.Body("hello world") +// }) +func (p *ControllerRegistor) Head(pattern string, f FilterFunc) { + p.AddMethod("head", pattern, f) +} + +// add patch method +// usage: +// Patch("/api/:id", func(ctx *context.Context){ +// ctx.Output.Body("hello world") +// }) +func (p *ControllerRegistor) Patch(pattern string, f FilterFunc) { + p.AddMethod("patch", pattern, f) +} + +// add options method +// usage: +// Options("/api/:id", func(ctx *context.Context){ +// ctx.Output.Body("hello world") +// }) +func (p *ControllerRegistor) Options(pattern string, f FilterFunc) { + p.AddMethod("options", pattern, f) +} + +// add all method +// usage: +// Any("/api/:id", func(ctx *context.Context){ +// ctx.Output.Body("hello world") +// }) +func (p *ControllerRegistor) Any(pattern string, f FilterFunc) { + p.AddMethod("*", pattern, f) +} + +// add http method router +// usage: +// AddMethod("get","/api/:id", func(ctx *context.Context){ +// ctx.Output.Body("hello world") +// }) +func (p *ControllerRegistor) AddMethod(method, pattern string, f FilterFunc) { + if method != "*" && !utils.InSlice(strings.ToLower(method), HTTPMETHOD) { + panic("not support http method: " + method) + } + route := &controllerInfo{} + route.routerType = routerTypeRESTFul + route.runfunction = f + methods := make(map[string]string) + if method == "*" { + for _, val := range HTTPMETHOD { + methods[val] = val + } + } else { + methods[method] = method + } + route.methods = methods + paramnums, params, parts := p.splitRoute(pattern) + if paramnums == 0 { + //now create the Route + route.pattern = pattern + p.fixrouters = append(p.fixrouters, route) + } else { + //recreate the url pattern, with parameters replaced + //by regular expressions. then compile the regex + pattern = strings.Join(parts, "/") + regex, regexErr := regexp.Compile(pattern) + if regexErr != nil { + panic(regexErr) + } + //now create the Route + route.regex = regex + route.params = params + route.pattern = pattern + p.routers = append(p.routers, route) + } +} + +func (p *ControllerRegistor) Handler(pattern string, h http.Handler) { + paramnums, params, parts := p.splitRoute(pattern) + route := &controllerInfo{} + route.routerType = routerTypeHandler + route.handler = h + if paramnums == 0 { + route.pattern = pattern + p.fixrouters = append(p.fixrouters, route) + } else { + //recreate the url pattern, with parameters replaced + //by regular expressions. then compile the regex + pattern = strings.Join(parts, "/") + regex, regexErr := regexp.Compile(pattern) + if regexErr != nil { + panic(regexErr) + } + //now create the Route + route.regex = regex + route.params = params + route.pattern = pattern + p.routers = append(p.routers, route) + } +} + +// analisys the patter to params & parts +func (p *ControllerRegistor) splitRoute(pattern string) (paramnums int, params map[int]string, parts []string) { + parts = strings.Split(pattern, "/") j := 0 - params := make(map[int]string) + params = make(map[int]string) for i, part := range parts { if strings.HasPrefix(part, ":") { expr := "(.*)" @@ -180,63 +390,7 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface, mappingM parts[i] = string(out) } } - reflectVal := reflect.ValueOf(c) - t := reflect.Indirect(reflectVal).Type() - methods := make(map[string]string) - if len(mappingMethods) > 0 { - semi := strings.Split(mappingMethods[0], ";") - for _, v := range semi { - colon := strings.Split(v, ":") - if len(colon) != 2 { - panic("method mapping format is invalid") - } - comma := strings.Split(colon[0], ",") - for _, m := range comma { - if m == "*" || utils.InSlice(strings.ToLower(m), HTTPMETHOD) { - if val := reflectVal.MethodByName(colon[1]); val.IsValid() { - methods[strings.ToLower(m)] = colon[1] - } else { - panic(colon[1] + " method doesn't exist in the controller " + t.Name()) - } - } else { - panic(v + " is an invalid method mapping. Method doesn't exist " + m) - } - } - } - } - if j == 0 { - //now create the Route - route := &controllerInfo{} - route.pattern = pattern - route.controllerType = t - route.methods = methods - if len(methods) > 0 { - route.hasMethod = true - } - p.fixrouters = append(p.fixrouters, route) - } else { // add regexp routers - //recreate the url pattern, with parameters replaced - //by regular expressions. then compile the regex - pattern = strings.Join(parts, "/") - regex, regexErr := regexp.Compile(pattern) - if regexErr != nil { - //TODO add error handling here to avoid panic - panic(regexErr) - } - - //now create the Route - - route := &controllerInfo{} - route.regex = regex - route.params = params - route.pattern = pattern - route.methods = methods - if len(methods) > 0 { - route.hasMethod = true - } - route.controllerType = t - p.routers = append(p.routers, route) - } + return j, params, parts } // Add auto router to ControllerRegistor. @@ -501,6 +655,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) var runrouter reflect.Type var findrouter bool var runMethod string + var routerInfo *controllerInfo params := make(map[string]string) w := &responseWriter{writer: rw} @@ -584,6 +739,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) if requestPath == route.pattern { runMethod = p.getRunMethod(r.Method, context, route) if runMethod != "" { + routerInfo = route runrouter = route.controllerType findrouter = true break @@ -598,6 +754,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) if requestPath[n-1] == '/' && route.pattern+"/" == requestPath { runMethod = p.getRunMethod(r.Method, context, route) if runMethod != "" { + routerInfo = route runrouter = route.controllerType findrouter = true break @@ -636,6 +793,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) } runMethod = p.getRunMethod(r.Method, context, route) if runMethod != "" { + routerInfo = route runrouter = route.controllerType context.Input.Params = params findrouter = true @@ -706,65 +864,82 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) if do_filter(BeforeExec) { goto Admin } - - //Invoke the request handler - vc := reflect.New(runrouter) - execController, ok := vc.Interface().(ControllerInterface) - if !ok { - panic("controller is not ControllerInterface") - } - - //call the controller init function - execController.Init(context, runrouter.Name(), runMethod, vc.Interface()) - - //if XSRF is Enable then check cookie where there has any cookie in the request's cookie _csrf - if EnableXSRF { - execController.XsrfToken() - if r.Method == "POST" || r.Method == "DELETE" || r.Method == "PUT" || - (r.Method == "POST" && (r.Form.Get("_method") == "delete" || r.Form.Get("_method") == "put")) { - execController.CheckXsrfCookie() + isRunable := false + if routerInfo != nil { + if routerInfo.routerType == routerTypeRESTFul { + if _, ok := routerInfo.methods[strings.ToLower(r.Method)]; ok { + isRunable = true + routerInfo.runfunction(context) + } else { + middleware.Exception("405", rw, r, "Method Not Allowed") + goto Admin + } + } else if routerInfo.routerType == routerTypeHandler { + isRunable = true + routerInfo.handler.ServeHTTP(rw, r) } } - //call prepare function - execController.Prepare() - - if !w.started { - //exec main logic - switch runMethod { - case "Get": - execController.Get() - case "Post": - execController.Post() - case "Delete": - execController.Delete() - case "Put": - execController.Put() - case "Head": - execController.Head() - case "Patch": - execController.Patch() - case "Options": - execController.Options() - default: - in := make([]reflect.Value, 0) - method := vc.MethodByName(runMethod) - method.Call(in) + if !isRunable { + //Invoke the request handler + vc := reflect.New(runrouter) + execController, ok := vc.Interface().(ControllerInterface) + if !ok { + panic("controller is not ControllerInterface") } - //render template - if !w.started && !context.Input.IsWebsocket() { - if AutoRender { - if err := execController.Render(); err != nil { - panic(err) - } + //call the controller init function + execController.Init(context, runrouter.Name(), runMethod, vc.Interface()) + //if XSRF is Enable then check cookie where there has any cookie in the request's cookie _csrf + if EnableXSRF { + execController.XsrfToken() + if r.Method == "POST" || r.Method == "DELETE" || r.Method == "PUT" || + (r.Method == "POST" && (r.Form.Get("_method") == "delete" || r.Form.Get("_method") == "put")) { + execController.CheckXsrfCookie() } } - } - // finish all runrouter. release resource - execController.Finish() + //call prepare function + execController.Prepare() + + if !w.started { + //exec main logic + switch runMethod { + case "Get": + execController.Get() + case "Post": + execController.Post() + case "Delete": + execController.Delete() + case "Put": + execController.Put() + case "Head": + execController.Head() + case "Patch": + execController.Patch() + case "Options": + execController.Options() + default: + in := make([]reflect.Value, 0) + method := vc.MethodByName(runMethod) + method.Call(in) + } + + //render template + if !w.started && !context.Input.IsWebsocket() { + if AutoRender { + if err := execController.Render(); err != nil { + panic(err) + } + + } + } + } + + // finish all runrouter. release resource + execController.Finish() + } //execute middleware filters if do_filter(AfterExec) { diff --git a/router_test.go b/router_test.go index 810177cf..a5e1a23e 100644 --- a/router_test.go +++ b/router_test.go @@ -10,6 +10,8 @@ import ( "net/http" "net/http/httptest" "testing" + + "github.com/astaxie/beego/context" ) type TestController struct { @@ -232,3 +234,47 @@ func TestAutoPrefix(t *testing.T) { t.Errorf("TestAutoPrefix can't run") } } + +func TestRouterGet(t *testing.T) { + r, _ := http.NewRequest("GET", "/user", nil) + w := httptest.NewRecorder() + + handler := NewControllerRegistor() + handler.Get("/user", func(ctx *context.Context) { + ctx.Output.Body([]byte("Get userlist")) + }) + handler.ServeHTTP(w, r) + if w.Body.String() != "Get userlist" { + t.Errorf("TestRouterGet can't run") + } +} + +func TestRouterPost(t *testing.T) { + r, _ := http.NewRequest("POST", "/user/123", nil) + w := httptest.NewRecorder() + + handler := NewControllerRegistor() + handler.Post("/user/:id", func(ctx *context.Context) { + ctx.Output.Body([]byte(ctx.Input.Param(":id"))) + }) + handler.ServeHTTP(w, r) + if w.Body.String() != "123" { + t.Errorf("TestRouterPost can't run") + } +} + +func sayhello(w http.ResponseWriter, r *http.Request) { + w.Write([]byte("sayhello")) +} + +func TestRouterHandler(t *testing.T) { + r, _ := http.NewRequest("POST", "/sayhi", nil) + w := httptest.NewRecorder() + + handler := NewControllerRegistor() + handler.Handler("/sayhi", http.HandlerFunc(sayhello)) + handler.ServeHTTP(w, r) + if w.Body.String() != "sayhello" { + t.Errorf("TestRouterHandler can't run") + } +} From b647026dfffd0f4cbb0d2e98749cf7c7fe28c6cc Mon Sep 17 00:00:00 2001 From: slene Date: Fri, 16 May 2014 13:14:15 +0800 Subject: [PATCH 21/27] orm: add test for unexported struct field --- orm/models_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/orm/models_test.go b/orm/models_test.go index 785088be..775c2856 100644 --- a/orm/models_test.go +++ b/orm/models_test.go @@ -210,6 +210,8 @@ type User struct { Nums int Langs SliceStringField `orm:"size(100)"` Extra JsonField `orm:"type(text)"` + unexport bool `orm:"-"` + unexport_ bool } func (u *User) TableIndex() [][]string { From f6ce2656db49c01afbe4343c5462f3f509685d44 Mon Sep 17 00:00:00 2001 From: astaxie Date: Fri, 16 May 2014 23:47:15 +0800 Subject: [PATCH 22/27] beego: support namespace ns := beego.NewNamespace("/v1/api/") ns.Cond(func(ctx *context.Context)bool{ if ctx.Input.Domain() == "www.beego.me" { return true } return false }) .Filter("before", Authenticate) .Router("/order", &admin.OrderController{}) .Get("/version",func (ctx *context.Context) { ctx.Output.Body([]byte("1.0.0")) }) .Post("/login",func (ctx *context.Context) { if ctx.Query("username") == "admin" && ctx.Query("username") == "password" { } }) .Namespace( NewNamespace("/shop"). Get("/order/:id", func(ctx *context.Context) { ctx.Output.Body([]byte(ctx.Input.Param(":id"))) }), ) --- app.go | 4 +- beego.go | 4 +- namespace.go | 137 ++++++++++++++++++++++++++++++++++++++++++++++ namespace_test.go | 137 ++++++++++++++++++++++++++++++++++++++++++++++ router.go | 17 +++++- 5 files changed, 294 insertions(+), 5 deletions(-) create mode 100644 namespace.go create mode 100644 namespace_test.go diff --git a/app.go b/app.go index 3344d1a5..6a56bb25 100644 --- a/app.go +++ b/app.go @@ -181,8 +181,8 @@ func (app *App) Any(rootpath string, f FilterFunc) *App { } // add router for http.Handler -func (app *App) Handler(rootpath string, h http.Handler) *App { - app.Handlers.Handler(rootpath, h) +func (app *App) Handler(rootpath string, h http.Handler, options ...interface{}) *App { + app.Handlers.Handler(rootpath, h, options...) return app } diff --git a/beego.go b/beego.go index 3631a7c6..e97f8a78 100644 --- a/beego.go +++ b/beego.go @@ -170,8 +170,8 @@ func Any(rootpath string, f FilterFunc) *App { } // register router for own Handler -func Handler(rootpath string, h http.Handler) *App { - BeeApp.Handler(rootpath, h) +func Handler(rootpath string, h http.Handler, options ...interface{}) *App { + BeeApp.Handler(rootpath, h, options...) return BeeApp } diff --git a/namespace.go b/namespace.go new file mode 100644 index 00000000..b9c88074 --- /dev/null +++ b/namespace.go @@ -0,0 +1,137 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie +package beego + +import ( + "net/http" + "strings" + + beecontext "github.com/astaxie/beego/context" +) + +type namespaceCond func(*beecontext.Context) bool + +type Namespace struct { + prefix string + condition namespaceCond + handlers *ControllerRegistor +} + +func NewNamespace(prefix string) *Namespace { + cr := NewControllerRegistor() + return &Namespace{ + prefix: prefix, + handlers: cr, + } +} + +func (n *Namespace) Cond(cond namespaceCond) *Namespace { + n.condition = cond + return n +} + +func (n *Namespace) Filter(action string, filter FilterFunc) *Namespace { + if action == "before" { + action = "BeforeRouter" + } else if action == "after" { + action = "FinishRouter" + } + n.handlers.AddFilter("*", action, filter) + return n +} + +func (n *Namespace) Router(rootpath string, c ControllerInterface, mappingMethods ...string) *Namespace { + n.handlers.Add(rootpath, c, mappingMethods...) + return n +} + +func (n *Namespace) AutoRouter(c ControllerInterface) *Namespace { + n.handlers.AddAuto(c) + return n +} + +func (n *Namespace) AutoPrefix(prefix string, c ControllerInterface) *Namespace { + n.handlers.AddAutoPrefix(prefix, c) + return n +} + +func (n *Namespace) Get(rootpath string, f FilterFunc) *Namespace { + n.handlers.Get(rootpath, f) + return n +} + +func (n *Namespace) Post(rootpath string, f FilterFunc) *Namespace { + n.handlers.Post(rootpath, f) + return n +} + +func (n *Namespace) Delete(rootpath string, f FilterFunc) *Namespace { + n.handlers.Delete(rootpath, f) + return n +} + +func (n *Namespace) Put(rootpath string, f FilterFunc) *Namespace { + n.handlers.Put(rootpath, f) + return n +} + +func (n *Namespace) Head(rootpath string, f FilterFunc) *Namespace { + n.handlers.Head(rootpath, f) + return n +} + +func (n *Namespace) Options(rootpath string, f FilterFunc) *Namespace { + n.handlers.Options(rootpath, f) + return n +} + +func (n *Namespace) Patch(rootpath string, f FilterFunc) *Namespace { + n.handlers.Patch(rootpath, f) + return n +} + +func (n *Namespace) Any(rootpath string, f FilterFunc) *Namespace { + n.handlers.Any(rootpath, f) + return n +} + +func (n *Namespace) Handler(rootpath string, h http.Handler) *Namespace { + n.handlers.Handler(rootpath, h) + return n +} + +func (n *Namespace) Namespace(ns *Namespace) *Namespace { + n.handlers.Handler(ns.prefix, ns, true) + return n +} + +func (n *Namespace) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + //trim the preifix from URL.Path + r.URL.Path = strings.TrimPrefix(r.URL.Path, n.prefix) + // init context + context := &beecontext.Context{ + ResponseWriter: rw, + Request: r, + Input: beecontext.NewInput(r), + Output: beecontext.NewOutput(), + } + context.Output.Context = context + context.Output.EnableGzip = EnableGzip + + if context.Input.IsWebsocket() { + context.ResponseWriter = rw + } + if n.condition != nil && !n.condition(context) { + http.Error(rw, "Method Not Allowed", 405) + } + n.handlers.ServeHTTP(rw, r) +} + +func AddNamespace(nl ...*Namespace) { + for _, n := range nl { + Handler(n.prefix, n, true) + } +} diff --git a/namespace_test.go b/namespace_test.go new file mode 100644 index 00000000..48500004 --- /dev/null +++ b/namespace_test.go @@ -0,0 +1,137 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + +package beego + +import ( + "net/http" + "net/http/httptest" + "strconv" + "testing" + + "github.com/astaxie/beego/context" +) + +func TestNamespaceGet(t *testing.T) { + r, _ := http.NewRequest("GET", "/v1/user", nil) + w := httptest.NewRecorder() + + ns := NewNamespace("/v1") + ns.Get("/user", func(ctx *context.Context) { + ctx.Output.Body([]byte("v1_user")) + }) + ns.ServeHTTP(w, r) + if w.Body.String() != "v1_user" { + t.Errorf("TestNamespaceGet can't run, get the response is " + w.Body.String()) + } +} + +func TestNamespacePost(t *testing.T) { + r, _ := http.NewRequest("POST", "/v1/user/123", nil) + w := httptest.NewRecorder() + + ns := NewNamespace("/v1") + ns.Post("/user/:id", func(ctx *context.Context) { + ctx.Output.Body([]byte(ctx.Input.Param(":id"))) + }) + ns.ServeHTTP(w, r) + if w.Body.String() != "123" { + t.Errorf("TestNamespacePost can't run, get the response is " + w.Body.String()) + } +} + +func TestNamespaceNest(t *testing.T) { + r, _ := http.NewRequest("GET", "/v1/admin/order", nil) + w := httptest.NewRecorder() + + ns := NewNamespace("/v1") + ns.Namespace( + NewNamespace("/admin"). + Get("/order", func(ctx *context.Context) { + ctx.Output.Body([]byte("order")) + }), + ) + ns.ServeHTTP(w, r) + if w.Body.String() != "order" { + t.Errorf("TestNamespaceNest can't run, get the response is " + w.Body.String()) + } +} + +func TestNamespaceNestParam(t *testing.T) { + r, _ := http.NewRequest("GET", "/v1/admin/order/123", nil) + w := httptest.NewRecorder() + + ns := NewNamespace("/v1") + ns.Namespace( + NewNamespace("/admin"). + Get("/order/:id", func(ctx *context.Context) { + ctx.Output.Body([]byte(ctx.Input.Param(":id"))) + }), + ) + ns.ServeHTTP(w, r) + if w.Body.String() != "123" { + t.Errorf("TestNamespaceNestParam can't run, get the response is " + w.Body.String()) + } +} + +func TestNamespaceFilter(t *testing.T) { + r, _ := http.NewRequest("GET", "/v1/user/123", nil) + w := httptest.NewRecorder() + + ns := NewNamespace("/v1") + ns.Filter("before", func(ctx *context.Context) { + ctx.Output.Body([]byte("this is Filter")) + }). + Get("/user/:id", func(ctx *context.Context) { + ctx.Output.Body([]byte(ctx.Input.Param(":id"))) + }) + ns.ServeHTTP(w, r) + if w.Body.String() != "this is Filter" { + t.Errorf("TestNamespaceFilter can't run, get the response is " + w.Body.String()) + } +} + +func TestNamespaceRouter(t *testing.T) { + r, _ := http.NewRequest("GET", "/v1/api/list", nil) + w := httptest.NewRecorder() + + ns := NewNamespace("/v1") + ns.Router("/api/list", &TestController{}, "*:List") + ns.ServeHTTP(w, r) + if w.Body.String() != "i am list" { + t.Errorf("TestNamespaceRouter can't run, get the response is " + w.Body.String()) + } +} + +func TestNamespaceAutoFunc(t *testing.T) { + r, _ := http.NewRequest("GET", "/v1/test/list", nil) + w := httptest.NewRecorder() + + ns := NewNamespace("/v1") + ns.AutoRouter(&TestController{}) + ns.ServeHTTP(w, r) + if w.Body.String() != "i am list" { + t.Errorf("user define func can't run") + } +} + +func TestNamespaceCond(t *testing.T) { + r, _ := http.NewRequest("GET", "/v1/test/list", nil) + w := httptest.NewRecorder() + + ns := NewNamespace("/v1") + ns.Cond(func(ctx *context.Context) bool { + if ctx.Input.Domain() == "beego.me" { + return true + } + return false + }). + AutoRouter(&TestController{}) + ns.ServeHTTP(w, r) + if w.Code != 405 { + t.Errorf("TestNamespaceCond can't run get the result " + strconv.Itoa(w.Code)) + } +} diff --git a/router.go b/router.go index 557bdc8b..3d6c1664 100644 --- a/router.go +++ b/router.go @@ -69,6 +69,7 @@ type controllerInfo struct { handler http.Handler runfunction FilterFunc routerType int + isPrefix bool } // ControllerRegistor containers registered router rules, controller handlers and filters. @@ -277,11 +278,16 @@ func (p *ControllerRegistor) AddMethod(method, pattern string, f FilterFunc) { } } -func (p *ControllerRegistor) Handler(pattern string, h http.Handler) { +func (p *ControllerRegistor) Handler(pattern string, h http.Handler, options ...interface{}) { paramnums, params, parts := p.splitRoute(pattern) route := &controllerInfo{} route.routerType = routerTypeHandler route.handler = h + if len(options) > 0 { + if v, ok := options[0].(bool); ok { + route.isPrefix = v + } + } if paramnums == 0 { route.pattern = pattern p.fixrouters = append(p.fixrouters, route) @@ -446,6 +452,7 @@ func (p *ControllerRegistor) AddFilter(pattern, action string, filter FilterFunc if err != nil { return err } + switch action { case "BeforeRouter": p.filters[BeforeRouter] = append(p.filters[BeforeRouter], mr) @@ -760,6 +767,14 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) break } } + if route.routerType == routerTypeHandler && route.isPrefix && + strings.HasPrefix(requestPath, route.pattern) { + + routerInfo = route + runrouter = route.controllerType + findrouter = true + break + } } } From 34ddcef1dc16f49c3d8fd3453e3d332c31e7f54c Mon Sep 17 00:00:00 2001 From: astaxie Date: Sat, 17 May 2014 00:12:25 +0800 Subject: [PATCH 23/27] beego: XSRF support Controller level fix #610 default value is true when you Enable Global XSRF, also can control in the prepare function to change the value. --- controller.go | 5 +++++ router.go | 6 +++--- templatefunc.go | 7 ++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/controller.go b/controller.go index 13acbbff..7098c1b5 100644 --- a/controller.go +++ b/controller.go @@ -47,6 +47,7 @@ type Controller struct { XSRFExpire int AppController interface{} EnableRender bool + EnableXSRF bool } // ControllerInterface is an interface to uniform all controller handler. @@ -76,6 +77,7 @@ func (c *Controller) Init(ctx *context.Context, controllerName, actionName strin c.TplExt = "tpl" c.AppController = app c.EnableRender = true + c.EnableXSRF = true c.Data = ctx.Input.Data } @@ -441,6 +443,9 @@ func (c *Controller) XsrfToken() string { // the token can provided in request header "X-Xsrftoken" and "X-CsrfToken" // or in form field value named as "_xsrf". func (c *Controller) CheckXsrfCookie() bool { + if !c.EnableXSRF { + return true + } token := c.GetString("_xsrf") if token == "" { token = c.Ctx.Request.Header.Get("X-Xsrftoken") diff --git a/router.go b/router.go index 3d6c1664..9220234f 100644 --- a/router.go +++ b/router.go @@ -906,6 +906,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) //call the controller init function execController.Init(context, runrouter.Name(), runMethod, vc.Interface()) + //call prepare function + execController.Prepare() + //if XSRF is Enable then check cookie where there has any cookie in the request's cookie _csrf if EnableXSRF { execController.XsrfToken() @@ -915,9 +918,6 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) } } - //call prepare function - execController.Prepare() - if !w.started { //exec main logic switch runMethod { diff --git a/templatefunc.go b/templatefunc.go index c7bd9238..62584781 100644 --- a/templatefunc.go +++ b/templatefunc.go @@ -186,16 +186,21 @@ func Htmlunquote(src string) string { // UrlFor returns url string with another registered controller handler with params. // usage: +// // UrlFor(".index") // print UrlFor("index") +// router /login // print UrlFor("login") // print UrlFor("login", "next","/"") -// print UrlFor("profile", "username","John Doe") +// router /profile/:username +// print UrlFor("profile", ":username","John Doe") // result: // / // /login // /login?next=/ // /user/John%20Doe +// +// more detail http://beego.me/docs/mvc/controller/urlbuilding.md func UrlFor(endpoint string, values ...string) string { return BeeApp.UrlFor(endpoint, values...) } From 237aaadd65053e1f30063fa61ed5edfdc97539d1 Mon Sep 17 00:00:00 2001 From: astaxie Date: Sat, 17 May 2014 00:43:51 +0800 Subject: [PATCH 24/27] session:support struct. gob.Register(v) --- session/sess_test.go | 9 +++++++++ session/sess_utils.go | 3 +++ 2 files changed, 12 insertions(+) diff --git a/session/sess_test.go b/session/sess_test.go index 17947862..1db55a64 100644 --- a/session/sess_test.go +++ b/session/sess_test.go @@ -16,6 +16,7 @@ func Test_gob(t *testing.T) { a := make(map[interface{}]interface{}) a["username"] = "astaxie" a[12] = 234 + a["user"] = User{"asta", "xie"} b, err := EncodeGob(a) if err != nil { t.Error(err) @@ -33,6 +34,14 @@ func Test_gob(t *testing.T) { if c[12] != 234 { t.Error("decode int error") } + if c["user"].(User).Username != "asta" { + t.Error("decode struct error") + } +} + +type User struct { + Username string + NickName string } func TestGenerate(t *testing.T) { diff --git a/session/sess_utils.go b/session/sess_utils.go index a9cce75a..8bc6c192 100644 --- a/session/sess_utils.go +++ b/session/sess_utils.go @@ -34,6 +34,9 @@ func init() { } func EncodeGob(obj map[interface{}]interface{}) ([]byte, error) { + for _, v := range obj { + gob.Register(v) + } buf := bytes.NewBuffer(nil) enc := gob.NewEncoder(buf) err := enc.Encode(obj) From 31a63c5d501af4c0e625496dda2af7c5c0dfcf91 Mon Sep 17 00:00:00 2001 From: astaxie Date: Sat, 17 May 2014 01:19:47 +0800 Subject: [PATCH 25/27] session: support memcache interface --- cache/memcache/memcache.go | 8 +- session/memcache/sess_memcache.go | 212 ++++++++++++++++++++++++++++++ 2 files changed, 217 insertions(+), 3 deletions(-) create mode 100644 session/memcache/sess_memcache.go diff --git a/cache/memcache/memcache.go b/cache/memcache/memcache.go index 7eea77c8..37658ffe 100644 --- a/cache/memcache/memcache.go +++ b/cache/memcache/memcache.go @@ -137,9 +137,11 @@ func (rc *MemcacheCache) StartAndGC(config string) error { } rc.conninfo = cf["conn"] var err error - rc.c, err = rc.connectInit() - if err != nil { - return errors.New("dial tcp conn error") + if rc.c != nil { + rc.c, err = rc.connectInit() + if err != nil { + return errors.New("dial tcp conn error") + } } return nil } diff --git a/session/memcache/sess_memcache.go b/session/memcache/sess_memcache.go new file mode 100644 index 00000000..fa8fa165 --- /dev/null +++ b/session/memcache/sess_memcache.go @@ -0,0 +1,212 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + +package session + +import ( + "net/http" + "sync" + + "github.com/astaxie/beego/session" + + "github.com/beego/memcache" +) + +var mempder = &MemProvider{} + +// memcache session store +type MemcacheSessionStore struct { + c *memcache.Connection + sid string + lock sync.RWMutex + values map[interface{}]interface{} + maxlifetime int64 +} + +// set value in memcache session +func (rs *MemcacheSessionStore) Set(key, value interface{}) error { + rs.lock.Lock() + defer rs.lock.Unlock() + rs.values[key] = value + return nil +} + +// get value in memcache session +func (rs *MemcacheSessionStore) Get(key interface{}) interface{} { + rs.lock.RLock() + defer rs.lock.RUnlock() + if v, ok := rs.values[key]; ok { + return v + } else { + return nil + } +} + +// delete value in memcache session +func (rs *MemcacheSessionStore) Delete(key interface{}) error { + rs.lock.Lock() + defer rs.lock.Unlock() + delete(rs.values, key) + return nil +} + +// clear all values in memcache session +func (rs *MemcacheSessionStore) Flush() error { + rs.lock.Lock() + defer rs.lock.Unlock() + rs.values = make(map[interface{}]interface{}) + return nil +} + +// get redis session id +func (rs *MemcacheSessionStore) SessionID() string { + return rs.sid +} + +// save session values to redis +func (rs *MemcacheSessionStore) SessionRelease(w http.ResponseWriter) { + defer rs.c.Close() + // if rs.values is empty, return directly + if len(rs.values) < 1 { + rs.c.Delete(rs.sid) + return + } + + b, err := session.EncodeGob(rs.values) + if err != nil { + return + } + rs.c.Set(rs.sid, 0, uint64(rs.maxlifetime), b) +} + +// redis session provider +type MemProvider struct { + maxlifetime int64 + savePath string + poolsize int + password string +} + +// init redis session +// savepath like +// e.g. 127.0.0.1:9090 +func (rp *MemProvider) SessionInit(maxlifetime int64, savePath string) error { + rp.maxlifetime = maxlifetime + rp.savePath = savePath + return nil +} + +// read redis session by sid +func (rp *MemProvider) SessionRead(sid string) (session.SessionStore, error) { + conn, err := rp.connectInit() + if err != nil { + return nil, err + } + kvs, err := conn.Get(sid) + if err != nil { + return nil, err + } + var contain []byte + if len(kvs) > 0 { + contain = kvs[0].Value + } + var kv map[interface{}]interface{} + if len(contain) == 0 { + kv = make(map[interface{}]interface{}) + } else { + kv, err = session.DecodeGob(contain) + if err != nil { + return nil, err + } + } + + rs := &MemcacheSessionStore{c: conn, sid: sid, values: kv, maxlifetime: rp.maxlifetime} + return rs, nil +} + +// check redis session exist by sid +func (rp *MemProvider) SessionExist(sid string) bool { + conn, err := rp.connectInit() + if err != nil { + return false + } + defer conn.Close() + if kvs, err := conn.Get(sid); err != nil || len(kvs) == 0 { + return false + } else { + return true + } +} + +// generate new sid for redis session +func (rp *MemProvider) SessionRegenerate(oldsid, sid string) (session.SessionStore, error) { + conn, err := rp.connectInit() + if err != nil { + return nil, err + } + var contain []byte + if kvs, err := conn.Get(sid); err != nil || len(kvs) == 0 { + // oldsid doesn't exists, set the new sid directly + // ignore error here, since if it return error + // the existed value will be 0 + conn.Set(sid, 0, uint64(rp.maxlifetime), []byte("")) + } else { + conn.Delete(oldsid) + conn.Set(sid, 0, uint64(rp.maxlifetime), kvs[0].Value) + contain = kvs[0].Value + } + + var kv map[interface{}]interface{} + if len(contain) == 0 { + kv = make(map[interface{}]interface{}) + } else { + kv, err = session.DecodeGob(contain) + if err != nil { + return nil, err + } + } + + rs := &MemcacheSessionStore{c: conn, sid: sid, values: kv, maxlifetime: rp.maxlifetime} + return rs, nil +} + +// delete redis session by id +func (rp *MemProvider) SessionDestroy(sid string) error { + conn, err := rp.connectInit() + if err != nil { + return err + } + defer conn.Close() + + _, err = conn.Delete(sid) + if err != nil { + return err + } + return nil +} + +// Impelment method, no used. +func (rp *MemProvider) SessionGC() { + return +} + +// @todo +func (rp *MemProvider) SessionAll() int { + return 0 +} + +// connect to memcache and keep the connection. +func (rp *MemProvider) connectInit() (*memcache.Connection, error) { + c, err := memcache.Connect(rp.savePath) + if err != nil { + return nil, err + } + return c, nil +} + +func init() { + session.Register("memcache", mempder) +} From 6bdf0838ceab0dc264c355b51b6173b1c001524a Mon Sep 17 00:00:00 2001 From: astaxie Date: Sat, 17 May 2014 01:26:59 +0800 Subject: [PATCH 26/27] beego: controller add ServeFormatted ServeFormatted serve Xml OR Json, depending on the value of the Accept header --- controller.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/controller.go b/controller.go index 7098c1b5..71287811 100644 --- a/controller.go +++ b/controller.go @@ -25,6 +25,13 @@ import ( "github.com/astaxie/beego/utils" ) +//commonly used mime-types +const ( + applicationJson = "application/json" + applicationXml = "applicatoin/xml" + textXml = "text/xml" +) + var ( // custom error when user stop request handler manually. USERSTOPRUN = errors.New("User stop run") @@ -287,6 +294,20 @@ func (c *Controller) ServeXml() { c.Ctx.Output.Xml(c.Data["xml"], hasIndent) } +// ServeFormatted serve Xml OR Json, depending on the value of the Accept header + +func (c *Controller) ServeFormatted() { + accept := c.Ctx.Input.Header("Accept") + switch accept { + case applicationJson: + c.ServeJson() + case applicationXml, textXml: + c.ServeXml() + default: + c.ServeJson() + } +} + // Input returns the input data map from POST or PUT request body and query string. func (c *Controller) Input() url.Values { if c.Ctx.Request.Form == nil { From 2c59ff1cc6949bce12eb7f5b567c4c7554619336 Mon Sep 17 00:00:00 2001 From: astaxie Date: Sat, 17 May 2014 02:20:48 +0800 Subject: [PATCH 27/27] beego: admin support link --- admin.go | 52 +++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/admin.go b/admin.go index ffaed11e..d908565d 100644 --- a/admin.go +++ b/admin.go @@ -9,6 +9,7 @@ package beego import ( "fmt" "net/http" + "strconv" "time" "github.com/astaxie/beego/toolbox" @@ -53,15 +54,16 @@ func init() { // AdminIndex is the default http.Handler for admin module. // it matches url pattern "/". func adminIndex(rw http.ResponseWriter, r *http.Request) { - rw.Write([]byte("Welcome to Admin Dashboard\n")) - rw.Write([]byte("There are servral functions:\n")) - rw.Write([]byte("1. Record all request and request time, http://localhost:8088/qps\n")) - rw.Write([]byte("2. Get runtime profiling data by the pprof, http://localhost:8088/prof\n")) - rw.Write([]byte("3. Get healthcheck result from http://localhost:8088/healthcheck\n")) - rw.Write([]byte("4. Get current task infomation from task http://localhost:8088/task \n")) - rw.Write([]byte("5. To run a task passed a param http://localhost:8088/runtask\n")) - rw.Write([]byte("6. Get all confige & router infomation http://localhost:8088/listconf\n")) - + rw.Write([]byte("beego admin dashboard")) + rw.Write([]byte("Welcome to Admin Dashboard
\n")) + rw.Write([]byte("There are servral functions:
\n")) + rw.Write([]byte("1. Record all request and request time, http://localhost:" + strconv.Itoa(AdminHttpPort) + "/qps
\n")) + rw.Write([]byte("2. Get runtime profiling data by the pprof, http://localhost:" + strconv.Itoa(AdminHttpPort) + "/prof
\n")) + rw.Write([]byte("3. Get healthcheck result from http://localhost:" + strconv.Itoa(AdminHttpPort) + "/healthcheck
\n")) + rw.Write([]byte("4. Get current task infomation from task http://localhost:" + strconv.Itoa(AdminHttpPort) + "/task
\n")) + rw.Write([]byte("5. To run a task passed a param http://localhost:" + strconv.Itoa(AdminHttpPort) + "/runtask
\n")) + rw.Write([]byte("6. Get all confige & router infomation http://localhost:" + strconv.Itoa(AdminHttpPort) + "/listconf
\n")) + rw.Write([]byte("")) } // QpsIndex is the http.Handler for writing qbs statistics map result info in http.ResponseWriter. @@ -180,10 +182,12 @@ func listConf(rw http.ResponseWriter, r *http.Request) { rw.Write([]byte("command not support")) } } else { - rw.Write([]byte("ListConf support this command:\n")) - rw.Write([]byte("1. command=conf\n")) - rw.Write([]byte("2. command=router\n")) - rw.Write([]byte("3. command=filter\n")) + rw.Write([]byte("beego admin dashboard")) + rw.Write([]byte("ListConf support this command:
\n")) + rw.Write([]byte("1. command=conf
\n")) + rw.Write([]byte("2. command=router
\n")) + rw.Write([]byte("3. command=filter
\n")) + rw.Write([]byte("")) } } @@ -195,16 +199,18 @@ func profIndex(rw http.ResponseWriter, r *http.Request) { if command != "" { toolbox.ProcessInput(command, rw) } else { - rw.Write([]byte("request url like '/prof?command=lookup goroutine'\n")) - rw.Write([]byte("the command have below types:\n")) - rw.Write([]byte("1. lookup goroutine\n")) - rw.Write([]byte("2. lookup heap\n")) - rw.Write([]byte("3. lookup threadcreate\n")) - rw.Write([]byte("4. lookup block\n")) - rw.Write([]byte("5. start cpuprof\n")) - rw.Write([]byte("6. stop cpuprof\n")) - rw.Write([]byte("7. get memprof\n")) - rw.Write([]byte("8. gc summary\n")) + rw.Write([]byte("beego admin dashboard")) + rw.Write([]byte("request url like '/prof?command=lookup goroutine'
\n")) + rw.Write([]byte("the command have below types:
\n")) + rw.Write([]byte("1. lookup goroutine
\n")) + rw.Write([]byte("2. lookup heap
\n")) + rw.Write([]byte("3. lookup threadcreate
\n")) + rw.Write([]byte("4. lookup block
\n")) + rw.Write([]byte("5. start cpuprof
\n")) + rw.Write([]byte("6. stop cpuprof
\n")) + rw.Write([]byte("7. get memprof
\n")) + rw.Write([]byte("8. gc summary
\n")) + rw.Write([]byte("")) } }