1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-04 18:57:03 +00:00

Give an easier and more permant solution for https://github.com/kataras/iris/pull/689

Former-commit-id: 8dc16d15f7bd14cb98b91b16d7d6b1bd756132bd
This commit is contained in:
kataras
2017-07-29 04:27:58 +03:00
parent 6176888e68
commit 6432759dbf
8 changed files with 333 additions and 10 deletions

View File

@@ -13,6 +13,12 @@ import (
"golang.org/x/crypto/acme/autocert"
)
// Configurator provides an easy way to modify
// the Supervisor.
//
// Look the `Configure` func for more.
type Configurator func(su *Supervisor)
// Supervisor is the wrapper and the manager for a compatible server
// and it's relative actions, called Tasks.
//
@@ -54,6 +60,22 @@ func New(srv *http.Server) *Supervisor {
}
}
// Configure accepts one or more `Configurator`.
// With this function you can use simple functions
// that are spread across your app to modify
// the supervisor, these Configurators can be
// used on any Supervisor instance.
//
// Look `Configurator` too.
//
// Returns itself.
func (su *Supervisor) Configure(configurators ...Configurator) *Supervisor {
for _, conf := range configurators {
conf(su)
}
return su
}
// DeferFlow defers the flow of the exeuction,
// i.e: when server should return error and exit
// from app, a DeferFlow call inside a Task