mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 13:40:55 +00:00
controller can controller whether render the template.
EnableReander default is true.
This commit is contained in:
parent
74804bc586
commit
bbc71142d7
@ -45,6 +45,7 @@ type Controller struct {
|
|||||||
CruSession session.SessionStore
|
CruSession session.SessionStore
|
||||||
XSRFExpire int
|
XSRFExpire int
|
||||||
AppController interface{}
|
AppController interface{}
|
||||||
|
EnableReander bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// ControllerInterface is an interface to uniform all controller handler.
|
// ControllerInterface is an interface to uniform all controller handler.
|
||||||
@ -74,6 +75,7 @@ func (c *Controller) Init(ctx *context.Context, controllerName, actionName strin
|
|||||||
c.Ctx = ctx
|
c.Ctx = ctx
|
||||||
c.TplExt = "tpl"
|
c.TplExt = "tpl"
|
||||||
c.AppController = app
|
c.AppController = app
|
||||||
|
c.EnableReander = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare runs after Init before request function execution.
|
// Prepare runs after Init before request function execution.
|
||||||
@ -123,6 +125,9 @@ func (c *Controller) Options() {
|
|||||||
|
|
||||||
// Render sends the response with rendered template bytes as text/html type.
|
// Render sends the response with rendered template bytes as text/html type.
|
||||||
func (c *Controller) Render() error {
|
func (c *Controller) Render() error {
|
||||||
|
if !c.EnableReander {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
rb, err := c.RenderBytes()
|
rb, err := c.RenderBytes()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user