54c89c0d by slene

Merge branch 'master' of github.com:astaxie/beego

2 parents 1c52f683 c3bc2bed
...@@ -16,7 +16,6 @@ type Context struct { ...@@ -16,7 +16,6 @@ type Context struct {
16 func (ctx *Context) Redirect(status int, localurl string) { 16 func (ctx *Context) Redirect(status int, localurl string) {
17 ctx.Output.Header("Location", localurl) 17 ctx.Output.Header("Location", localurl)
18 ctx.Output.SetStatus(status) 18 ctx.Output.SetStatus(status)
19 ctx.Output.Body([]byte(" "))
20 } 19 }
21 20
22 func (ctx *Context) Abort(status int, body string) { 21 func (ctx *Context) Abort(status int, body string) {
......
...@@ -24,10 +24,15 @@ import ( ...@@ -24,10 +24,15 @@ import (
24 "github.com/astaxie/beego/session" 24 "github.com/astaxie/beego/session"
25 ) 25 )
26 26
27 var (
28 USERSTOPRUN = errors.New("User stop run")
29 )
30
27 type Controller struct { 31 type Controller struct {
28 Ctx *context.Context 32 Ctx *context.Context
29 Data map[interface{}]interface{} 33 Data map[interface{}]interface{}
30 ChildName string 34 controllerName string
35 actionName string
31 TplNames string 36 TplNames string
32 Layout string 37 Layout string
33 TplExt string 38 TplExt string
...@@ -39,7 +44,7 @@ type Controller struct { ...@@ -39,7 +44,7 @@ type Controller struct {
39 } 44 }
40 45
41 type ControllerInterface interface { 46 type ControllerInterface interface {
42 Init(ct *context.Context, childName string, app interface{}) 47 Init(ct *context.Context, controllerName, actionName string, app interface{})
43 Prepare() 48 Prepare()
44 Get() 49 Get()
45 Post() 50 Post()
...@@ -52,11 +57,12 @@ type ControllerInterface interface { ...@@ -52,11 +57,12 @@ type ControllerInterface interface {
52 Render() error 57 Render() error
53 } 58 }
54 59
55 func (c *Controller) Init(ctx *context.Context, childName string, app interface{}) { 60 func (c *Controller) Init(ctx *context.Context, controllerName, actionName string, app interface{}) {
56 c.Data = make(map[interface{}]interface{}) 61 c.Data = make(map[interface{}]interface{})
57 c.Layout = "" 62 c.Layout = ""
58 c.TplNames = "" 63 c.TplNames = ""
59 c.ChildName = childName 64 c.controllerName = controllerName
65 c.actionName = actionName
60 c.Ctx = ctx 66 c.Ctx = ctx
61 c.TplExt = "tpl" 67 c.TplExt = "tpl"
62 c.AppController = app 68 c.AppController = app
...@@ -119,7 +125,7 @@ func (c *Controller) RenderBytes() ([]byte, error) { ...@@ -119,7 +125,7 @@ func (c *Controller) RenderBytes() ([]byte, error) {
119 //if the controller has set layout, then first get the tplname's content set the content to the layout 125 //if the controller has set layout, then first get the tplname's content set the content to the layout
120 if c.Layout != "" { 126 if c.Layout != "" {
121 if c.TplNames == "" { 127 if c.TplNames == "" {
122 c.TplNames = c.ChildName + "/" + strings.ToLower(c.Ctx.Request.Method) + "." + c.TplExt 128 c.TplNames = strings.ToLower(c.controllerName) + "/" + strings.ToLower(c.actionName) + "." + c.TplExt
123 } 129 }
124 if RunMode == "dev" { 130 if RunMode == "dev" {
125 BuildTemplate(ViewsPath) 131 BuildTemplate(ViewsPath)
...@@ -146,7 +152,7 @@ func (c *Controller) RenderBytes() ([]byte, error) { ...@@ -146,7 +152,7 @@ func (c *Controller) RenderBytes() ([]byte, error) {
146 return icontent, nil 152 return icontent, nil
147 } else { 153 } else {
148 if c.TplNames == "" { 154 if c.TplNames == "" {
149 c.TplNames = c.ChildName + "/" + strings.ToLower(c.Ctx.Request.Method) + "." + c.TplExt 155 c.TplNames = strings.ToLower(c.controllerName) + "/" + strings.ToLower(c.actionName) + "." + c.TplExt
150 } 156 }
151 if RunMode == "dev" { 157 if RunMode == "dev" {
152 BuildTemplate(ViewsPath) 158 BuildTemplate(ViewsPath)
...@@ -181,7 +187,7 @@ func (c *Controller) Abort(code string) { ...@@ -181,7 +187,7 @@ func (c *Controller) Abort(code string) {
181 } 187 }
182 188
183 func (c *Controller) StopRun() { 189 func (c *Controller) StopRun() {
184 panic("") 190 panic(USERSTOPRUN)
185 } 191 }
186 192
187 func (c *Controller) UrlFor(endpoint string, values ...string) string { 193 func (c *Controller) UrlFor(endpoint string, values ...string) string {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!