From 7c610ee7c97639d123e60541a08554ec3121e03e Mon Sep 17 00:00:00 2001 From: astaxie Date: Thu, 25 Jul 2013 16:00:42 +0800 Subject: [PATCH 1/5] fix reflect find methodByName --- router.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/router.go b/router.go index b793b2bd..8e8f3d91 100644 --- a/router.go +++ b/router.go @@ -94,7 +94,8 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface, mappingM } } } - t := reflect.Indirect(reflect.ValueOf(c)).Type() + reflectVal := reflect.Indirect(reflect.ValueOf(c)) + t := reflectVal.Type() methods := make(map[string]string) if len(mappingMethods) > 0 { semi := strings.Split(mappingMethods[0], ";") @@ -106,7 +107,7 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface, mappingM comma := strings.Split(colon[0], ",") for _, m := range comma { if m == "*" || inSlice(strings.ToLower(m), HTTPMETHOD) { - if _, ok := t.MethodByName(colon[1]); ok { + if val := reflectVal.FieldByName(colon[1]); val.IsValid() { methods[strings.ToLower(m)] = colon[1] } else { panic(colon[1] + " method don't exist in the controller " + t.Name()) From ab08aa9c9e6343a9eab8ddeb6b567b93128e3493 Mon Sep 17 00:00:00 2001 From: astaxie Date: Thu, 25 Jul 2013 16:08:18 +0800 Subject: [PATCH 2/5] MethodByName --- router.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/router.go b/router.go index 8e8f3d91..e7409ecc 100644 --- a/router.go +++ b/router.go @@ -94,8 +94,8 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface, mappingM } } } - reflectVal := reflect.Indirect(reflect.ValueOf(c)) - t := reflectVal.Type() + reflectVal := reflect.ValueOf(c) + t := reflect.Indirect(reflectVal).Type() methods := make(map[string]string) if len(mappingMethods) > 0 { semi := strings.Split(mappingMethods[0], ";") @@ -107,7 +107,7 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface, mappingM comma := strings.Split(colon[0], ",") for _, m := range comma { if m == "*" || inSlice(strings.ToLower(m), HTTPMETHOD) { - if val := reflectVal.FieldByName(colon[1]); val.IsValid() { + if val := reflectVal.MethodByName(colon[1]); val.IsValid() { methods[strings.ToLower(m)] = colon[1] } else { panic(colon[1] + " method don't exist in the controller " + t.Name()) From 259617f68dd4e3093bceab688b7a561f5834054f Mon Sep 17 00:00:00 2001 From: astaxie Date: Thu, 25 Jul 2013 16:40:37 +0800 Subject: [PATCH 3/5] remove markdown --- template.go | 1 - utils.go | 9 --------- 2 files changed, 10 deletions(-) diff --git a/template.go b/template.go index 2112f806..654bdf3f 100644 --- a/template.go +++ b/template.go @@ -23,7 +23,6 @@ func init() { beegoTplFuncMap = make(template.FuncMap) BeeTemplateExt = make([]string, 0) BeeTemplateExt = append(BeeTemplateExt, "tpl", "html") - beegoTplFuncMap["markdown"] = MarkDown beegoTplFuncMap["dateformat"] = DateFormat beegoTplFuncMap["date"] = Date beegoTplFuncMap["compare"] = Compare diff --git a/utils.go b/utils.go index dc1c75fd..c5b27638 100644 --- a/utils.go +++ b/utils.go @@ -2,7 +2,6 @@ package beego import ( "fmt" - "github.com/russross/blackfriday" "html/template" "regexp" "strings" @@ -17,14 +16,6 @@ func webTime(t time.Time) string { return ftime } -// MarkDown parses a string in MarkDown format and returns HTML. Used by the template parser as "markdown" -func MarkDown(raw string) (output template.HTML) { - input := []byte(raw) - bOutput := blackfriday.MarkdownBasic(input) - output = template.HTML(string(bOutput)) - return -} - func Substr(s string, start, length int) string { bt := []rune(s) if start < 0 { From c2bb6b30688f0277d5f8d77576bbee4e882a9afe Mon Sep 17 00:00:00 2001 From: eXthen Date: Thu, 25 Jul 2013 18:57:40 +0800 Subject: [PATCH 4/5] Update log.go --- log.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log.go b/log.go index ef3bc958..cd0af2d4 100644 --- a/log.go +++ b/log.go @@ -32,7 +32,7 @@ type FileLogWriter struct { rotate bool - startLock sync.Mutex //only one log can writer to the file + startLock sync.Mutex //only one log can write to the file } type MuxWriter struct { From ff11bcdb7c1c0d80b394f5a56aa806d1c7bea026 Mon Sep 17 00:00:00 2001 From: eXthen Date: Thu, 25 Jul 2013 19:04:26 +0800 Subject: [PATCH 5/5] I guess write would be better --- log.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log.go b/log.go index cd0af2d4..7e0e84b2 100644 --- a/log.go +++ b/log.go @@ -32,7 +32,7 @@ type FileLogWriter struct { rotate bool - startLock sync.Mutex //only one log can write to the file + startLock sync.Mutex // Only one log can write to the file } type MuxWriter struct {