ghttp_server_plugin.go 911 B

12345678910111213141516171819202122
  1. // Copyright 2019 gf Author(https://github.com/gogf/gf). All Rights Reserved.
  2. //
  3. // This Source Code Form is subject to the terms of the MIT License.
  4. // If a copy of the MIT was not distributed with this file,
  5. // You can obtain one at https://github.com/gogf/gf.
  6. package ghttp
  7. // Plugin is the interface for server plugin.
  8. type Plugin interface {
  9. Name() string // Name returns the name of the plugin.
  10. Author() string // Author returns the author of the plugin.
  11. Version() string // Version returns the version of the plugin, like "v1.0.0".
  12. Description() string // Description returns the description of the plugin.
  13. Install(s *Server) error // Install installs the plugin before server starts.
  14. Remove() error // Remove removes the plugin.
  15. }
  16. // Plugin adds plugin to server.
  17. func (s *Server) Plugin(plugin ...Plugin) {
  18. s.plugins = append(s.plugins, plugin...)
  19. }