1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-19 10:57:05 +00:00

Add a third, simple, example for folder structuring as requested at https://github.com/kataras/iris/issues/748

One change to code base but it will be described at the next version:

Error Handlers (`app.OnErrorCode/OnAnyErrorCode`)  respect the `app.UseGlobal`'s middlewares now (not the `app.Use` for reasons we can all understand, hopefully).


Former-commit-id: ec97bbb04548f9932cf4d7b950be513b70747bcb
This commit is contained in:
Gerasimos (Makis) Maropoulos
2017-10-01 16:29:25 +03:00
parent ba63031871
commit 38c6241055
16 changed files with 308 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
package identity
import (
"time"
"github.com/kataras/iris"
"github.com/kataras/iris/_examples/structuring/handler-based/bootstrap"
)
// New returns a new handler which adds some headers and view data
// describing the application, i.e the owner, the startup time.
func New(b *bootstrap.Bootstrapper) iris.Handler {
return func(ctx iris.Context) {
// response headers
ctx.Header("App-Name", b.AppName)
ctx.Header("App-Owner", b.AppOwner)
ctx.Header("App-Since", time.Since(b.AppSpawnDate).String())
ctx.Header("Server", "Iris: https://iris-go.com")
// view data if ctx.View or c.Tmpl = "$page.html" will be called next.
ctx.ViewData("AppName", b.AppName)
ctx.ViewData("AppOwner", b.AppOwner)
ctx.Next()
}
}
// Configure creates a new identity middleware and registers that to the app.
func Configure(b *bootstrap.Bootstrapper) {
h := New(b)
b.UseGlobal(h)
}