controller can controller whether render the template.
EnableReander default is true.
Showing
1 changed file
with
5 additions
and
0 deletions
| ... | @@ -45,6 +45,7 @@ type Controller struct { | ... | @@ -45,6 +45,7 @@ type Controller struct { |
| 45 | CruSession session.SessionStore | 45 | CruSession session.SessionStore |
| 46 | XSRFExpire int | 46 | XSRFExpire int |
| 47 | AppController interface{} | 47 | AppController interface{} |
| 48 | EnableReander bool | ||
| 48 | } | 49 | } |
| 49 | 50 | ||
| 50 | // ControllerInterface is an interface to uniform all controller handler. | 51 | // ControllerInterface is an interface to uniform all controller handler. |
| ... | @@ -74,6 +75,7 @@ func (c *Controller) Init(ctx *context.Context, controllerName, actionName strin | ... | @@ -74,6 +75,7 @@ func (c *Controller) Init(ctx *context.Context, controllerName, actionName strin |
| 74 | c.Ctx = ctx | 75 | c.Ctx = ctx |
| 75 | c.TplExt = "tpl" | 76 | c.TplExt = "tpl" |
| 76 | c.AppController = app | 77 | c.AppController = app |
| 78 | c.EnableReander = true | ||
| 77 | } | 79 | } |
| 78 | 80 | ||
| 79 | // Prepare runs after Init before request function execution. | 81 | // Prepare runs after Init before request function execution. |
| ... | @@ -123,6 +125,9 @@ func (c *Controller) Options() { | ... | @@ -123,6 +125,9 @@ func (c *Controller) Options() { |
| 123 | 125 | ||
| 124 | // Render sends the response with rendered template bytes as text/html type. | 126 | // Render sends the response with rendered template bytes as text/html type. |
| 125 | func (c *Controller) Render() error { | 127 | func (c *Controller) Render() error { |
| 128 | if !c.EnableReander { | ||
| 129 | return nil | ||
| 130 | } | ||
| 126 | rb, err := c.RenderBytes() | 131 | rb, err := c.RenderBytes() |
| 127 | 132 | ||
| 128 | if err != nil { | 133 | if err != nil { | ... | ... |
-
Please register or sign in to post a comment