diff --git a/README.md b/README.md
index 37b91e3b..705875d9 100644
--- a/README.md
+++ b/README.md
@@ -65,6 +65,7 @@ Iris may have reached version 8, but we're not stopping there. We have many feat
* [Dockerize](https://github.com/iris-contrib/cloud-native-go)
* [Community & Support](#-community)
* [Blogs](https://iris-go.com/v8/blogs)
+ - [Iris Go vs .NET Core Kestrel in terms of HTTP performance](https://hackernoon.com/iris-go-vs-net-core-kestrel-in-terms-of-http-performance-806195dc93d5)
- [Go vs .NET Core in terms of HTTP performance](https://medium.com/@kataras/go-vs-net-core-in-terms-of-http-performance-7535a61b67b8)
- [Iris, a modular web framework](https://medium.com/@corebreaker/iris-web-cd684b4685c7)
- [Deploying a Iris Golang app in hasura](https://docs.hasura.io/0.14/tutorials/deploying-a-go-iris-app.html)
@@ -84,33 +85,8 @@ $ go get -u github.com/kataras/iris
> _iris_ takes advantage of the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature. You get truly reproducible builds, as this method guards against upstream renames and deletes.
-```go
-// file: main.go
-package main
-import "github.com/kataras/iris"
-
-func main() {
- app := iris.New()
- // Load all templates from the "./templates" folder
- // where extension is ".html" and parse them
- // using the standard `html/template` package.
- app.RegisterView(iris.HTML("./templates", ".html"))
-
- // Method: GET
- // Resource: http://localhost:8080
- app.Get("/", func(ctx iris.Context) {
- // Bind: {{.message}} with "Hello world!"
- ctx.ViewData("message", "Hello world!")
- // Render template file: ./templates/hello.html
- ctx.View("hello.html")
- })
-
- // Start the server using a network address.
- app.Run(iris.Addr(":8080"))
-}
-```
```html
-
+
Hello Page
@@ -121,6 +97,75 @@ func main() {
```
+```go
+// file: main.go
+package main
+import "github.com/kataras/iris"
+
+func main() {
+ app := iris.New()
+ // Load all templates from the "./views" folder
+ // where extension is ".html" and parse them
+ // using the standard `html/template` package.
+ app.RegisterView(iris.HTML("./views", ".html"))
+
+ // Method: GET
+ // Resource: http://localhost:8080
+ app.Get("/", func(ctx iris.Context) {
+ // Bind: {{.message}} with "Hello world!"
+ ctx.ViewData("message", "Hello world!")
+ // Render template file: ./views/hello.html
+ ctx.View("hello.html")
+ })
+
+ // Method: GET
+ // Resource: http://localhost:8080/user/42
+ app.Get("/user/{id:long}", func(ctx iris.Context) {
+ userID, _ := ctx.Params().GetInt64("id")
+ ctx.Writef("User ID: %d", userID)
+ })
+
+ // Start the server using a network address.
+ app.Run(iris.Addr(":8080"))
+}
+```
+
+Fan of the MVC Architectural Pattern? Click here
+
+```go
+package main
+
+import "github.com/kataras/iris"
+
+func main() {
+ app := iris.New()
+ app.RegisterView(iris.HTML("./views", ".html"))
+
+ app.Controller("/", new(Controller))
+
+ app.Run(iris.Addr(":8080"))
+}
+
+type Controller struct {
+ iris.Controller
+}
+
+// Method: GET
+// Resource: http://localhost:8080
+func (c *Controller) Get() {
+ c.Data["message"] = "Hello world!"
+ c.Tmpl = "hello.html"
+}
+
+// Method: GET
+// Resource: http://localhost:8080/user/42
+func (c *Controller) GetBy(id int64) {
+ c.Ctx.Writef("User ID: %d", id)
+}
+```
+
+
+
```sh
$ go run main.go
> Now listening on: http://localhost:8080
diff --git a/_examples/mvc/controller-with-model-and-view/main.go b/_examples/mvc/controller-with-model-and-view/main.go
index a1b89e78..61da2a35 100644
--- a/_examples/mvc/controller-with-model-and-view/main.go
+++ b/_examples/mvc/controller-with-model-and-view/main.go
@@ -4,7 +4,6 @@ import (
"sync"
"github.com/kataras/iris"
- "github.com/kataras/iris/mvc"
)
func main() {
@@ -52,7 +51,7 @@ var myDB = &DB{
// ProfileController our example user controller which controls
// the paths of "/profile" "/profile/{id:int}" and "/profile/me".
type ProfileController struct {
- mvc.Controller // IMPORTANT
+ iris.Controller // IMPORTANT
User UserModel `iris:"model"`
// we will bind it but you can also tag it with`iris:"persistence"`
diff --git a/_examples/mvc/hello-world/main.go b/_examples/mvc/hello-world/main.go
index 58d17a0b..86ca97eb 100644
--- a/_examples/mvc/hello-world/main.go
+++ b/_examples/mvc/hello-world/main.go
@@ -2,7 +2,6 @@ package main
import (
"github.com/kataras/iris"
- "github.com/kataras/iris/mvc"
"github.com/kataras/iris/middleware/logger"
"github.com/kataras/iris/middleware/recover"
@@ -48,9 +47,8 @@ func main() {
// IndexController serves the "/".
type IndexController struct {
- // if you build with go1.9 you can omit the import of mvc package
- // and just use `iris.Controller` instead.
- mvc.Controller
+ // if you build with go1.8 you have to use the mvc package, `mvc.Controller` instead.
+ iris.Controller
}
// Get serves
@@ -62,7 +60,7 @@ func (c *IndexController) Get() {
// PingController serves the "/ping".
type PingController struct {
- mvc.Controller
+ iris.Controller
}
// Get serves
@@ -74,7 +72,7 @@ func (c *PingController) Get() {
// HelloController serves the "/hello".
type HelloController struct {
- mvc.Controller
+ iris.Controller
}
type myJSONData struct {
diff --git a/_examples/mvc/login/user/auth.go b/_examples/mvc/login/user/auth.go
index ba7c0053..cda9d3dd 100644
--- a/_examples/mvc/login/user/auth.go
+++ b/_examples/mvc/login/user/auth.go
@@ -6,7 +6,6 @@ import (
"strings"
"github.com/kataras/iris"
- "github.com/kataras/iris/mvc"
)
// paths
@@ -22,7 +21,7 @@ const (
// AuthController is the user authentication controller, a custom shared controller.
type AuthController struct {
- mvc.SessionController
+ iris.SessionController
Source *DataSource
User Model `iris:"model"`
diff --git a/_examples/mvc/session-controller/main.go b/_examples/mvc/session-controller/main.go
index 0e3e16d4..4a294353 100644
--- a/_examples/mvc/session-controller/main.go
+++ b/_examples/mvc/session-controller/main.go
@@ -4,15 +4,12 @@ import (
"time"
"github.com/kataras/iris"
- "github.com/kataras/iris/mvc"
"github.com/kataras/iris/sessions"
)
type VisitController struct {
- // if you build with go1.9 you can omit the import of mvc package
- // and just use `iris.Controller` instead.
- mvc.SessionController
+ iris.SessionController
StartTime time.Time
}
diff --git a/context.go b/context.go
index 64cd0006..bec37e4c 100644
--- a/context.go
+++ b/context.go
@@ -122,4 +122,8 @@ type (
// the "github.com/kataras/iris/mvc"
// package for machines that have not installed go1.9 yet.
Controller = mvc.Controller
+ // SessionController is a simple `Controller` implementation
+ // which requires a binded session manager in order to give
+ // direct access to the current client's session via its `Session` field.
+ SessionController = mvc.SessionController
)
diff --git a/doc.go b/doc.go
index fee4c586..d86fa52b 100644
--- a/doc.go
+++ b/doc.go
@@ -682,7 +682,6 @@ Example Code
import (
"github.com/kataras/iris"
- "github.com/kataras/iris/mvc"
"github.com/kataras/iris/middleware/logger"
"github.com/kataras/iris/middleware/recover"
@@ -720,9 +719,8 @@ Example Code
// IndexController serves the "/".
type IndexController struct {
- // if you build with go1.9 you can omit the import of mvc package
- // and just use `iris.Controller` instead.
- mvc.Controller
+ // if you build with go1.8 you have to use the mvc package, `mvc.Controller` instead.
+ iris.Controller
}
// Get serves
@@ -734,7 +732,7 @@ Example Code
// PingController serves the "/ping".
type PingController struct {
- mvc.Controller
+ iris.Controller
}
// Get serves
@@ -746,7 +744,7 @@ Example Code
// HelloController serves the "/hello".
type HelloController struct {
- mvc.Controller
+ iris.Controller
}
// Get serves
@@ -811,7 +809,7 @@ useful to call middlewares or when many methods use the same collection of data.
Optional `EndRequest(ctx)` function to perform any finalization after any method executed.
-Inheritance, recursively, see for example our `mvc.SessionController`, it has the `mvc.Controller` as an embedded field
+Inheritance, recursively, see for example our `mvc.SessionController/iris.SessionController`, it has the `mvc.Controller/iris.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.