2020-01-17 21:12:52 +08:00
|
|
|
// Copyright 2019 gf Author(https://github.com/gogf/gf). All Rights Reserved.
|
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
|
|
// If a copy of the MIT was not distributed with this file,
|
|
|
|
// You can obtain one at https://github.com/gogf/gf.
|
|
|
|
|
|
|
|
package ghttp
|
|
|
|
|
|
|
|
// Plugin is the interface for server plugin.
|
|
|
|
type Plugin interface {
|
|
|
|
Install(s *Server) error
|
|
|
|
Remove() error
|
|
|
|
}
|
|
|
|
|
|
|
|
// Plugin adds plugin for server.
|
|
|
|
func (s *Server) Plugin(plugin ...Plugin) {
|
|
|
|
for _, p := range plugin {
|
|
|
|
if err := p.Install(s); err != nil {
|
2020-01-21 15:42:08 +08:00
|
|
|
s.Logger().Fatal(err)
|
2020-01-17 21:12:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|