1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 02:17:05 +00:00

Give read access to the current route, a feature that many of you asked for

Former-commit-id: 39295ac1331ee08d3047c84f5c8ea152bce96781
This commit is contained in:
kataras
2017-08-23 16:46:55 +03:00
parent 8b5b6b116a
commit 8b3c44b0a3
8 changed files with 129 additions and 16 deletions

View File

@@ -64,6 +64,10 @@ import (
type Controller struct {
// Name contains the current controller's full name.
Name string
// Route is the current request context's route.
Route context.RouteReadOnly
// contains the `Name` as different words, all lowercase,
// without the "Controller" suffix if exists.
// we need this as field because the activator
@@ -178,6 +182,7 @@ func (c *Controller) RelTmpl() string {
// It's called internally.
// End-Developer can ovverride it but it still MUST be called.
func (c *Controller) BeginRequest(ctx context.Context) {
c.Route = ctx.GetCurrentRoute()
// path and path params
c.Path = ctx.Path()
c.Params = ctx.Params()