diff --git a/FAQ.md b/FAQ.md
index 7b7cc2f9..e6d242bd 100644
--- a/FAQ.md
+++ b/FAQ.md
@@ -55,4 +55,4 @@ Yes, https://chat.iris-go.com
By people like you, who help us by donating small or large amounts of money.
-Help this project deliver awesome and unique features with the highest possible code quality by donating any amount via [PayPal](https://www.paypal.me/kataras). Your name will be published [here](https://iris-go.com) after your approval via e-mail.
+Help this project deliver awesome and unique features with the highest possible code quality by donating any amount via [PayPal](https://iris-go.com/donate). Your name will be published [here](https://iris-go.com) after your approval via e-mail.
diff --git a/README.md b/README.md
index fea42d32..bab1d421 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@
# Iris Web Framework
-[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/kataras/iris) [![view examples](https://img.shields.io/badge/examples%20-173-a83adf.svg?style=for-the-badge&logo=go)](https://github.com/kataras/iris/tree/master/_examples) [![chat](https://img.shields.io/gitter/room/iris_go/community.svg?color=cc2b5e&logo=gitter&style=for-the-badge)](https://gitter.im/iris_go/community) [![donate](https://img.shields.io/badge/support-Iris-blue.svg?style=for-the-badge&logo=paypal)](https://www.paypal.me/kataras)
+[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/kataras/iris) [![view examples](https://img.shields.io/badge/examples%20-173-a83adf.svg?style=for-the-badge&logo=go)](https://github.com/kataras/iris/tree/master/_examples) [![chat](https://img.shields.io/gitter/room/iris_go/community.svg?color=cc2b5e&logo=gitter&style=for-the-badge)](https://gitter.im/iris_go/community) [![donate](https://img.shields.io/badge/support-Iris-blue.svg?style=for-the-badge&logo=paypal)](https://iris-go.com/donate)
@@ -32,8 +32,8 @@ Learn what [others saying about Iris](https://iris-go.com/testimonials/) and **[
```sh
# https://github.com/kataras/iris/wiki/Installation
$ go get github.com/kataras/iris/v12@master
-# assume the following code in example.go file
-$ cat example.go
+# assume the following code in main.go file
+$ cat main.go
```
```go
@@ -42,27 +42,24 @@ package main
import "github.com/kataras/iris/v12"
func main() {
- app := iris.New()
- app.Get("/ping", func(ctx iris.Context) {
- ctx.JSON(iris.Map{
- "message": "pong",
- })
- })
+ app := iris.New()
+ app.Get("/", index)
+ app.Listen(":8080")
+}
- app.Listen(":8080")
+func index(ctx iris.Context) {
+ ctx.HTML("
Hello, World!
")
}
```
```sh
-# run example.go and
-# visit http://localhost:8080/ping on browser
-$ go run example.go
+$ go run main.go
```
-> Routing is powered by [muxie](https://github.com/kataras/muxie), the most powerful and fastest trie-based software written in Go.
-
+[![run in the browser](https://img.shields.io/badge/Run-in%20the%20Browser-348798.svg?style=for-the-badge&logo=repl.it)](https://repl.it/@kataras/Iris-Hello-World)
+
Iris contains extensive and thorough **[wiki](https://github.com/kataras/iris/wiki)** making it easy to get started with the framework.
diff --git a/README_ES.md b/README_ES.md
index 8b62e2d4..fec5f5e9 100644
--- a/README_ES.md
+++ b/README_ES.md
@@ -1,6 +1,6 @@
# Iris Web Framework
-[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/kataras/iris) [![FOSSA Status](https://img.shields.io/badge/LICENSE%20SCAN-PASSING❤️-CD2956?style=for-the-badge&logo=fossa)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkataras%2Firis?ref=badge_shield) [![view examples](https://img.shields.io/badge/learn%20by-examples-0C8EC5.svg?style=for-the-badge&logo=go)](https://github.com/kataras/iris/tree/master/_examples) [![chat](https://img.shields.io/gitter/room/iris_go/community.svg?color=7E18DD&logo=gitter&style=for-the-badge)](https://gitter.im/iris_go/community)
+[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/kataras/iris) [![FOSSA Status](https://img.shields.io/badge/LICENSE%20SCAN-PASSING❤️-CD2956?style=for-the-badge&logo=fossa)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkataras%2Firis?ref=badge_shield) [![view examples](https://img.shields.io/badge/learn%20by-examples-0C8EC5.svg?style=for-the-badge&logo=go)](https://github.com/kataras/iris/tree/master/_examples) [![chat](https://img.shields.io/gitter/room/iris_go/community.svg?color=7E18DD&logo=gitter&style=for-the-badge)](https://gitter.im/iris_go/community)
Iris es un framework web rápido, simple pero con muchas funcionalidades y muy eficiente para Go. Proporciona una base bellamente expresiva y fácil de usar para su próximo sitio web o API.
diff --git a/README_FA.md b/README_FA.md
index a90af17b..dcdacaf8 100644
--- a/README_FA.md
+++ b/README_FA.md
@@ -2,7 +2,7 @@
-[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/kataras/iris) [![FOSSA Status](https://img.shields.io/badge/LICENSE%20SCAN-PASSING❤️-CD2956?style=for-the-badge&logo=fossa)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkataras%2Firis?ref=badge_shield) [![view examples](https://img.shields.io/badge/learn%20by-examples-0C8EC5.svg?style=for-the-badge&logo=go)](https://github.com/kataras/iris/tree/master/_examples) [![chat](https://img.shields.io/gitter/room/iris_go/community.svg?color=7E18DD&logo=gitter&style=for-the-badge)](https://gitter.im/iris_go/community)
+[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/kataras/iris) [![FOSSA Status](https://img.shields.io/badge/LICENSE%20SCAN-PASSING❤️-CD2956?style=for-the-badge&logo=fossa)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkataras%2Firis?ref=badge_shield) [![view examples](https://img.shields.io/badge/learn%20by-examples-0C8EC5.svg?style=for-the-badge&logo=go)](https://github.com/kataras/iris/tree/master/_examples) [![chat](https://img.shields.io/gitter/room/iris_go/community.svg?color=7E18DD&logo=gitter&style=for-the-badge)](https://gitter.im/iris_go/community)
diff --git a/README_FR.md b/README_FR.md
index 5d331265..1ab7394a 100644
--- a/README_FR.md
+++ b/README_FR.md
@@ -1,6 +1,6 @@
# Iris Web Framework
-[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/kataras/iris) [![FOSSA Status](https://img.shields.io/badge/LICENSE%20SCAN-PASSING❤️-CD2956?style=for-the-badge&logo=fossa)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkataras%2Firis?ref=badge_shield) [![view examples](https://img.shields.io/badge/learn%20by-examples-0C8EC5.svg?style=for-the-badge&logo=go)](https://github.com/kataras/iris/tree/master/_examples) [![chat](https://img.shields.io/gitter/room/iris_go/community.svg?color=7E18DD&logo=gitter&style=for-the-badge)](https://gitter.im/iris_go/community)
+[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/kataras/iris) [![FOSSA Status](https://img.shields.io/badge/LICENSE%20SCAN-PASSING❤️-CD2956?style=for-the-badge&logo=fossa)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkataras%2Firis?ref=badge_shield) [![view examples](https://img.shields.io/badge/learn%20by-examples-0C8EC5.svg?style=for-the-badge&logo=go)](https://github.com/kataras/iris/tree/master/_examples) [![chat](https://img.shields.io/gitter/room/iris_go/community.svg?color=7E18DD&logo=gitter&style=for-the-badge)](https://gitter.im/iris_go/community)
diff --git a/README_GR.md b/README_GR.md
index d7f5690c..b7d98ff6 100644
--- a/README_GR.md
+++ b/README_GR.md
@@ -1,6 +1,6 @@
# Iris Web Framework
-[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/kataras/iris) [![FOSSA Status](https://img.shields.io/badge/LICENSE%20SCAN-PASSING❤️-CD2956?style=for-the-badge&logo=fossa)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkataras%2Firis?ref=badge_shield) [![view examples](https://img.shields.io/badge/learn%20by-examples-0C8EC5.svg?style=for-the-badge&logo=go)](https://github.com/kataras/iris/tree/master/_examples) [![chat](https://img.shields.io/gitter/room/iris_go/community.svg?color=7E18DD&logo=gitter&style=for-the-badge)](https://gitter.im/iris_go/community)
+[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/kataras/iris) [![FOSSA Status](https://img.shields.io/badge/LICENSE%20SCAN-PASSING❤️-CD2956?style=for-the-badge&logo=fossa)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkataras%2Firis?ref=badge_shield) [![view examples](https://img.shields.io/badge/learn%20by-examples-0C8EC5.svg?style=for-the-badge&logo=go)](https://github.com/kataras/iris/tree/master/_examples) [![chat](https://img.shields.io/gitter/room/iris_go/community.svg?color=7E18DD&logo=gitter&style=for-the-badge)](https://gitter.im/iris_go/community)
Το Iris είναι ένα γρήγορο, απλό αλλά και πλήρως λειτουργικό και πολύ αποδοτικό web framework για τη Go γλώσσα προγραμματισμού. Παρέχει ένα εκφραστικό και εύχρηστο υπόβαθρο για την επόμενη ιστοσελίδα σας.
diff --git a/README_KO.md b/README_KO.md
index ba18083e..97bd485b 100644
--- a/README_KO.md
+++ b/README_KO.md
@@ -1,6 +1,6 @@
# Iris Web Framework
-[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/kataras/iris) [![FOSSA Status](https://img.shields.io/badge/LICENSE%20SCAN-PASSING❤️-CD2956?style=for-the-badge&logo=fossa)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkataras%2Firis?ref=badge_shield) [![view examples](https://img.shields.io/badge/learn%20by-examples-0C8EC5.svg?style=for-the-badge&logo=go)](https://github.com/kataras/iris/tree/master/_examples) [![chat](https://img.shields.io/gitter/room/iris_go/community.svg?color=7E18DD&logo=gitter&style=for-the-badge)](https://gitter.im/iris_go/community)
+[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/kataras/iris) [![FOSSA Status](https://img.shields.io/badge/LICENSE%20SCAN-PASSING❤️-CD2956?style=for-the-badge&logo=fossa)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkataras%2Firis?ref=badge_shield) [![view examples](https://img.shields.io/badge/learn%20by-examples-0C8EC5.svg?style=for-the-badge&logo=go)](https://github.com/kataras/iris/tree/master/_examples) [![chat](https://img.shields.io/gitter/room/iris_go/community.svg?color=7E18DD&logo=gitter&style=for-the-badge)](https://gitter.im/iris_go/community)
Iris는 단순하고 빠르며 좋은 성능과 모든 기능을 갖춘 Go언어용 웹 프레임워크입니다. 당신의 웹사이트나 API를 위해서 아름답고 사용하기 쉬운 기반을 제공합니다.
diff --git a/README_RU.md b/README_RU.md
index 4856ac3b..412456fb 100644
--- a/README_RU.md
+++ b/README_RU.md
@@ -1,6 +1,6 @@
# Iris Web Framework
-[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/kataras/iris) [![FOSSA Status](https://img.shields.io/badge/LICENSE%20SCAN-PASSING❤️-CD2956?style=for-the-badge&logo=fossa)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkataras%2Firis?ref=badge_shield) [![view examples](https://img.shields.io/badge/learn%20by-examples-0C8EC5.svg?style=for-the-badge&logo=go)](https://github.com/kataras/iris/tree/master/_examples) [![chat](https://img.shields.io/gitter/room/iris_go/community.svg?color=7E18DD&logo=gitter&style=for-the-badge)](https://gitter.im/iris_go/community)
+[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/kataras/iris) [![FOSSA Status](https://img.shields.io/badge/LICENSE%20SCAN-PASSING❤️-CD2956?style=for-the-badge&logo=fossa)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkataras%2Firis?ref=badge_shield) [![view examples](https://img.shields.io/badge/learn%20by-examples-0C8EC5.svg?style=for-the-badge&logo=go)](https://github.com/kataras/iris/tree/master/_examples) [![chat](https://img.shields.io/gitter/room/iris_go/community.svg?color=7E18DD&logo=gitter&style=for-the-badge)](https://gitter.im/iris_go/community)
Iris — это быстрый, простой, но полнофункциональный и эффективный веб-фреймворк для Go. Он обеспечивает красивую, выразительную и простую в использовании основу для вашего следующего веб-сайта или API.
Узнайте, что [говорят другие люди об Iris](https://iris-go.com/testimonials/) и поставьте **[звёздочку](https://github.com/kataras/iris/stargazers)** этому проекту с открытым исходным кодом, чтобы поддержать его потенциал.
diff --git a/README_ZH.md b/README_ZH.md
index 56cda87c..af329ae8 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -1,6 +1,6 @@
# Iris Web Framework
-[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/kataras/iris) [![FOSSA Status](https://img.shields.io/badge/LICENSE%20SCAN-PASSING❤️-CD2956?style=for-the-badge&logo=fossa)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkataras%2Firis?ref=badge_shield) [![view examples](https://img.shields.io/badge/learn%20by-examples-0C8EC5.svg?style=for-the-badge&logo=go)](https://github.com/kataras/iris/tree/master/_examples) [![chat](https://img.shields.io/gitter/room/iris_go/community.svg?color=7E18DD&logo=gitter&style=for-the-badge)](https://gitter.im/iris_go/community)
+[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/kataras/iris) [![FOSSA Status](https://img.shields.io/badge/LICENSE%20SCAN-PASSING❤️-CD2956?style=for-the-badge&logo=fossa)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkataras%2Firis?ref=badge_shield) [![view examples](https://img.shields.io/badge/learn%20by-examples-0C8EC5.svg?style=for-the-badge&logo=go)](https://github.com/kataras/iris/tree/master/_examples) [![chat](https://img.shields.io/gitter/room/iris_go/community.svg?color=7E18DD&logo=gitter&style=for-the-badge)](https://gitter.im/iris_go/community)
Iris 是基于 Go 编写的一个快速,简单但功能齐全且非常高效的 Web 框架。 它为您的下一个网站或 API 提供了一个非常富有表现力且易于使用的基础。
diff --git a/_examples/dependency-injection/context-register-dependency/main.go b/_examples/dependency-injection/context-register-dependency/main.go
new file mode 100644
index 00000000..8d73bbae
--- /dev/null
+++ b/_examples/dependency-injection/context-register-dependency/main.go
@@ -0,0 +1,95 @@
+package main
+
+import "github.com/kataras/iris/v12"
+
+func main() {
+ app := iris.New()
+ app.Use(RoleMiddleware)
+
+ app.Get("/", commonHandler)
+ c := app.ConfigureContainer()
+ /*
+ When you do NOT have access to the middleware code itself
+ then you can register a request dependency
+ which retrieves the value from the Context
+ and returns it, so handler/function's input arguments
+ with that `Role` type can be binded.
+
+ c.RegisterDependency(func(ctx iris.Context) Role {
+ role, ok := GetRole(ctx)
+ if !ok {
+ // This codeblock will never be executed here
+ // but you can stop executing a handler which depends on
+ // that dependency with `ctx.StopExecution/ctx.StopWithXXX` methods
+ // or by returning a second output argument of `error` type.
+ ctx.StopExecution()
+ return Role{}
+ }
+
+ return role
+ })
+ */
+ c.Get("/dep", handlerWithDependencies)
+
+ // http://localhost:8080?name=kataras
+ // http://localhost:8080/dep?name=kataras
+ app.Listen(":8080")
+}
+
+func commonHandler(ctx iris.Context) {
+ role, _ := GetRole(ctx)
+ ctx.WriteString(role.Name)
+}
+
+func handlerWithDependencies(role Role) string {
+ return role.Name
+}
+
+// Code for an example middleware.
+
+// Role struct value example.
+type Role struct {
+ Name string
+}
+
+const roleContextKey = "myapp.role"
+
+// RoleMiddleware example of a custom middleware.
+func RoleMiddleware(ctx iris.Context) {
+ // [do it yourself: extract the role from the request...]
+ if ctx.URLParam("name") != "kataras" {
+ ctx.StopWithStatus(iris.StatusUnauthorized)
+ return
+ }
+ //
+
+ role := Role{Name: "admin"}
+
+ ctx.Values().Set(roleContextKey, role)
+
+ // When you have access to the middleware itself:
+ // Use the `RegisterDependency` to register
+ // struct type values as dependencies at request-time for
+ // any potential dependency injection-ed user handler.
+ // This way the user of your middleware can get rid of
+ // manually register a dependency for that `Role` type with calls of
+ // `APIContainer.RegisterDependency` (and `mvc.Application.Register`).
+ ctx.RegisterDependency(role)
+
+ ctx.Next()
+}
+
+// GetRole returns the role inside the context values,
+// the `roleMiddleware` should be executed first.
+func GetRole(ctx iris.Context) (Role, bool) {
+ v := ctx.Values().Get(roleContextKey)
+ if v != nil {
+ if role, ok := v.(Role); ok {
+ return role, true
+ }
+ }
+
+ return Role{}, false
+}
+
+// End Code of our example middleware.
diff --git a/_examples/mvc/overview/README.md b/_examples/mvc/overview/README.md
index 7c6cf79d..e58e6ff7 100644
--- a/_examples/mvc/overview/README.md
+++ b/_examples/mvc/overview/README.md
@@ -92,9 +92,7 @@ Create a `database/database.go` file and copy-paste the following:
```go
package database
-import (
- "app/environment"
-)
+import "app/environment"
type DB interface {
Exec(q string) error
@@ -260,7 +258,7 @@ func (c *GreetController) Get(req model.Request) (model.Response, error) {
}
```
-The `GreetController` depends on the `GreetService`. It serves the `GET: /greet` index path through its `Get` method. The `Get` method expecting a `model.Request` which contains a single field name of `Name` which will be extracted from the `URL Query Parameter 'name'` (because it's a `GET` requst and its `url:"name"` struct field).
+The `GreetController` depends on the `GreetService`. It serves the `GET: /greet` index path through its `Get` method. The `Get` method accepts a `model.Request` which contains a single field name of `Name` which will be extracted from the `URL Query Parameter 'name'` (because it's a `GET` requst and its `url:"name"` struct field).
## Wrap up
@@ -364,14 +362,17 @@ Install [Go](https://golang.org/dl) and run the application with:
go run main.go
```
-### Docker
+Docker
+
+Download the [Dockerfile](https://raw.githubusercontent.com/kataras/iris/9b93c0dbb491dcedf49c91e89ca13bab884d116f/_examples/mvc/overview/Dockerfile) and [docker-compose.yml](https://raw.githubusercontent.com/kataras/iris/9b93c0dbb491dcedf49c91e89ca13bab884d116f/_examples/mvc/overview/docker-compose.yml) files to the `app` folder.
Install [Docker](https://www.docker.com/) and execute the following command:
```sh
$ docker-compose up
```
+
Visit http://localhost:8080?name=kataras.
-Now, replace the `main.go`'s `app.Register(environment.DEV` with `environment.PROD`, restart the application and refresh. You will see that a new database (`sqlite`) and another service of (`greeterWithLogging`) will be binded to the `GreetController`. With **a single change** you achieve to completety change the result.
+Optionally, replace the `main.go`'s `app.Register(environment.DEV` with `environment.PROD`, restart the application and refresh. You will see that a new database (`sqlite`) and another service of (`greeterWithLogging`) will be binded to the `GreetController`. With **a single change** you achieve to completety change the result.
diff --git a/_examples/mvc/overview/database/database.go b/_examples/mvc/overview/database/database.go
index 88f92210..c99e96c6 100644
--- a/_examples/mvc/overview/database/database.go
+++ b/_examples/mvc/overview/database/database.go
@@ -1,8 +1,6 @@
package database
-import (
- "app/environment"
-)
+import "app/environment"
// DB example database interface.
type DB interface {
diff --git a/_examples/mvc/session-controller/main.go b/_examples/mvc/session-controller/main.go
index 879d9a0a..953f6e69 100644
--- a/_examples/mvc/session-controller/main.go
+++ b/_examples/mvc/session-controller/main.go
@@ -33,25 +33,14 @@ func (c *VisitController) Get() string {
func newApp() *iris.Application {
app := iris.New()
+ // Configure sessions manager as we used to.
sess := sessions.New(sessions.Config{Cookie: "mysession_cookie_name"})
app.Use(sess.Handler())
visitApp := mvc.New(app)
- // bind the current *session.Session, which is required, to the `VisitController.Session`
- // and the time.Now() to the `VisitController.StartTime`.
- visitApp.Register(
- // if dependency is a function which accepts
- // a Context and returns a single value
- // then the result type of this function is resolved by the controller
- // and on each request it will call the function with its Context
- // and set the result(the *sessions.Session here) to the controller's field.
- //
- // If dependencies are registered without field or function's input arguments as
- // consumers then those dependencies are being ignored before the server ran,
- // so you can bind many dependecies and use them in different controllers.
- // sess.Start, // However after version 12.2 sessions are automatically binded.
- time.Now(),
- )
+ visitApp.Register(time.Now())
+ // The `VisitController.Session` is automatically binded to the current `sessions.Session`.
+
visitApp.Handle(new(VisitController))
return app
@@ -60,7 +49,7 @@ func newApp() *iris.Application {
func main() {
app := newApp()
- // 1. open the browser
+ // 1. Prepare a client, e.g. your browser
// 2. navigate to http://localhost:8080
// 3. refresh the page some times
// 4. close the browser
diff --git a/_examples/sessions/overview/main.go b/_examples/sessions/overview/main.go
index cf02f589..d04462ae 100644
--- a/_examples/sessions/overview/main.go
+++ b/_examples/sessions/overview/main.go
@@ -24,6 +24,17 @@ func main() {
DisableSubdomainPersistence: false,
// Allow getting the session value stored by the request from the same request.
AllowReclaim: true,
+ /*
+ SessionIDGenerator: func(ctx iris.Context) string {
+ id:= ctx.GetHeader("X-Session-Id")
+ if id == "" {
+ id = // [generate ID here and set the header]
+ ctx.Header("X-Session-Id", id)
+ }
+
+ return id
+ },
+ */
})
app := example.NewApp(sess)
diff --git a/context/context.go b/context/context.go
index 2269fb27..3396a5be 100644
--- a/context/context.go
+++ b/context/context.go
@@ -1153,11 +1153,12 @@ type Context interface {
// Controller returns a reflect Value of the custom Controller from which this handler executed.
// It will return a Kind() == reflect.Invalid if the handler was not executed from within a controller.
Controller() reflect.Value
- // RegisterDependency registers a struct dependency at serve-time
+ // RegisterDependency registers a struct or slice
+ // or pointer to struct dependency at request-time
// for the next handler in the chain. One value per type.
// Note that it's highly recommended to register
// your dependencies before server ran
- // through APIContainer(app.ConfigureContainer) or MVC(mvc.New)
+ // through Party.ConfigureContainer or mvc.Application.Register
// in sake of minimum performance cost.
//
// See `UnregisterDependency` too.
@@ -5562,12 +5563,15 @@ const DependenciesContextKey = "iris.dependencies"
// struct dependencies are stored with.
type DependenciesMap map[reflect.Type]reflect.Value
-// RegisterDependency registers a struct dependency at serve-time
+// RegisterDependency registers a struct or slice
+// or pointer to struct dependency at request-time
// for the next handler in the chain. One value per type.
// Note that it's highly recommended to register
// your dependencies before server ran
-// through APIContainer(app.ConfigureContainer) or MVC(mvc.New)
+// through Party.ConfigureContainer or mvc.Application.Register
// in sake of minimum performance cost.
+//
+// See `UnregisterDependency` too.
func (ctx *context) RegisterDependency(v interface{}) {
if v == nil {
return