本文整理匯總了Golang中github.com/mholt/caddy.Controller.ServerBlockStorage方法的典型用法代碼示例。如果您正苦於以下問題:Golang Controller.ServerBlockStorage方法的具體用法?Golang Controller.ServerBlockStorage怎麽用?Golang Controller.ServerBlockStorage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mholt/caddy.Controller
的用法示例。
在下文中一共展示了Controller.ServerBlockStorage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: setup
// setup used internally by Caddy to set up this middleware
func setup(c *caddy.Controller) error {
mc, err := parse(c)
if err != nil {
return err
}
if c.ServerBlockKeyIndex == 0 {
// only run when the first hostname has been loaded.
if mc.maillog, err = mc.maillog.Init(c.ServerBlockKeys...); err != nil {
return err
}
if err = mc.loadFromEnv(); err != nil {
return err
}
if err = mc.loadPGPKeys(); err != nil {
return err
}
if err = mc.loadTemplate(); err != nil {
return err
}
if err = mc.pingSMTP(); err != nil {
return err
}
c.ServerBlockStorage = newHandler(mc, startMailDaemon(mc))
}
c.OnShutdown(func() error {
if moh, ok := c.ServerBlockStorage.(*handler); ok {
if moh.reqPipe != nil {
close(moh.reqPipe)
moh.reqPipe = nil
}
}
return nil
})
fmt.Printf("%#v\n\n", c)
if moh, ok := c.ServerBlockStorage.(*handler); ok { // moh = mailOutHandler ;-)
httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler {
moh.Next = next
return moh
})
return nil
}
return errors.New("[mailout] Could not create the middleware handler")
}