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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user