1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 10:27:06 +00:00

Structuring examples - Pushed to iris-contrib/examples as well.

Former-commit-id: 24ee6ce233d83f0b394afc6c69b5a88243406045
This commit is contained in:
Gerasimos (Makis) Maropoulos
2017-10-22 16:04:11 +03:00
parent f95986d0c0
commit 11277f12a0
42 changed files with 32 additions and 270 deletions

View File

@@ -0,0 +1,33 @@
package identity
import (
"time"
"github.com/kataras/iris"
"github.com/kataras/iris/_examples/structuring/bootstrap/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)
}