diff --git a/HISTORY.md b/HISTORY.md index 3addec0b..c686d360 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -18,6 +18,30 @@ Developers are not forced to upgrade if they don't really need it. Upgrade whene **How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`. +# We, 23 August 2017 | v8.3.4 + +Give read access to the current request context's route, a feature that many of you asked a lot. + +```go +func(ctx context.Context) { + _ = ctx.GetCurrentRoute().Name() + // .Method() returns string, same as ctx.Method(). + // .Subdomain() returns string, the registered subdomain. + // .Path() returns string, the registered path. + // .IsOnline() returns boolean. +} +``` + +```go +type MyController struct { + mvc.Controller +} + +func (c *MyController) Get(){ + _ = c.Route.Name() // same as `c.Ctx.GetCurrentRoute().Name()`. + // [...] +} +``` # We, 23 August 2017 | v8.3.3 @@ -340,7 +364,7 @@ Access to the low-level `context.Context` via the `Ctx` field. Get the relative request path by using the controller's name via `RelPath()`. -Get the relative template path directory by using the controller's name via `RelTmpl`(). +Get the relative template path directory by using the controller's name via `RelTmpl()`. Flow as you used to, `Controllers` can be registered to any `Party`, including Subdomains, the Party's begin and done handlers work as expected. @@ -353,6 +377,7 @@ Optional `EndRequest(ctx)` function to perform any finalization after any method Inheritance, recursively, see for example our `mvc.SessionController`, it has the `mvc.Controller` as an embedded field and it adds its logic to its `BeginRequest`, [here](https://github.com/kataras/iris/blob/master/mvc/session_controller.go). +Read access to the current route via the `Route` field. **Using Iris MVC for code reuse** diff --git a/README.md b/README.md index a05e4d26..fcb00b3e 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Iris may have reached version 8, but we're not stopping there. We have many feat ### 📑 Table of contents * [Installation](#-installation) -* [Latest changes](https://github.com/kataras/iris/blob/master/HISTORY.md#we-23-august-2017--v833) +* [Latest changes](https://github.com/kataras/iris/blob/master/HISTORY.md#we-23-august-2017--v834) * [Learn](#-learn) * [HTTP Listening](_examples/#http-listening) * [Configuration](_examples/#configuration) diff --git a/VERSION b/VERSION index b0f66d95..fee113d0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.3.3:https://github.com/kataras/iris/blob/master/HISTORY.md#we-23-august-2017--v833 \ No newline at end of file +8.3.4:https://github.com/kataras/iris/blob/master/HISTORY.md#we-23-august-2017--v834 \ No newline at end of file diff --git a/context/route.go b/context/route.go index c56c4ffe..5f816cc6 100644 --- a/context/route.go +++ b/context/route.go @@ -5,11 +5,19 @@ package context type RouteReadOnly interface { // Name returns the route's name. Name() string - // String returns the form of METHOD, SUBDOMAIN, TMPL PATH. - String() string + + // Method returns the route's method. + Method() string + + // Subdomains returns the route's subdomain. + Subdomain() string + // Path returns the route's original registered path. Path() string + // String returns the form of METHOD, SUBDOMAIN, TMPL PATH. + String() string + // IsOnline returns true if the route is marked as "online" (state). IsOnline() bool diff --git a/core/router/route.go b/core/router/route.go index 8809f033..94937021 100644 --- a/core/router/route.go +++ b/core/router/route.go @@ -189,6 +189,10 @@ type routeReadOnlyWrapper struct { *Route } +func (rd routeReadOnlyWrapper) Method() string { + return rd.Route.Method +} + func (rd routeReadOnlyWrapper) Name() string { return rd.Route.Name } diff --git a/doc.go b/doc.go index 8182163a..c16be3a7 100644 --- a/doc.go +++ b/doc.go @@ -35,7 +35,7 @@ Source code and other details for the project are available at GitHub: Current Version -8.3.3 +8.3.4 Installation @@ -810,7 +810,7 @@ Access to the low-level `context.Context` via the `Ctx` field. Get the relative request path by using the controller's name via `RelPath()`. -Get the relative template path directory by using the controller's name via `RelTmpl`(). +Get the relative template path directory by using the controller's name via `RelTmpl()`. Flow as you used to, `Controllers` can be registered to any `Party`, including Subdomains, the Party's begin and done handlers work as expected. @@ -823,6 +823,8 @@ Optional `EndRequest(ctx)` function to perform any finalization after any method Inheritance, recursively, see for example our `mvc.SessionController`, it has the `mvc.Controller` as an embedded field and it adds its logic to its `BeginRequest`. Source file: https://github.com/kataras/iris/blob/master/mvc/session_controller.go. +Read access to the current route via the `Route` field. + Using Iris MVC for code reuse diff --git a/iris.go b/iris.go index c423e42c..bfe0e360 100644 --- a/iris.go +++ b/iris.go @@ -32,7 +32,7 @@ import ( const ( // Version is the current version number of the Iris Web Framework. - Version = "8.3.3" + Version = "8.3.4" ) // HTTP status codes as registered with IANA.