Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add Controller to RenderArgs, and add Action property

  • Loading branch information...
commit b6149532672ee7652c6e409e025954d4cdecff53 1 parent f3f16b5
@robfig authored
Showing with 5 additions and 1 deletion.
  1. +4 −1 controller.go
  2. +1 −0  mvc.go
View
5 controller.go
@@ -17,6 +17,7 @@ type Controller struct {
Type *ControllerType // A description of the controller type.
MethodType *MethodType // A description of the invoked action type.
AppController interface{} // The controller that was instantiated.
+ Action string // The full action name, e.g. "Application.Index"
Request *Request
Response *Response
@@ -32,7 +33,7 @@ type Controller struct {
}
func NewController(req *Request, resp *Response, ct *ControllerType) *Controller {
- return &Controller{
+ c := &Controller{
Name: ct.Type.Name(),
Type: ct,
Request: req,
@@ -43,6 +44,8 @@ func NewController(req *Request, resp *Response, ct *ControllerType) *Controller
"RunMode": RunMode,
},
}
+ c.RenderArgs["Controller"] = c
+ return c
}
func (c *Controller) FlashParams() {
View
1  mvc.go
@@ -47,6 +47,7 @@ func NewAppController(req *Request, resp *Response, controllerName, methodName s
appControllerPtr := initNewAppController(appControllerType.Type, controller)
// Set the method being called.
+ controller.Action = controllerName + "." + methodName
controller.AppController = appControllerPtr.Interface()
controller.MethodType = appControllerType.Method(methodName)
if controller.MethodType == nil {
Please sign in to comment.
Something went wrong with that request. Please try again.