modules.go 898 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package modules
  2. import (
  3. "fmt"
  4. "golang-fave/engine/wrapper"
  5. )
  6. type FuncFrontEnd func(wrap *wrapper.Wrapper)
  7. type FuncBackEnd func(wrap *wrapper.Wrapper)
  8. type Module struct {
  9. Id string
  10. Name string
  11. FrontEnd FuncFrontEnd
  12. BackEnd FuncBackEnd
  13. }
  14. type Modules struct {
  15. list map[string]Module
  16. }
  17. func New() *Modules {
  18. m := Modules{
  19. list: map[string]Module{},
  20. }
  21. return &m
  22. }
  23. func (this *Modules) Load() {
  24. // Called before server starts
  25. fmt.Println("Load modules")
  26. }
  27. // All actions here...
  28. // MySQL install
  29. // MySQL first user
  30. // User login
  31. // User logout
  32. // Called inside goroutine
  33. func (this *Modules) Action(wrap *wrapper.Wrapper) bool {
  34. //
  35. return false
  36. }
  37. // Called inside goroutine
  38. func (this *Modules) FrontEnd(wrap *wrapper.Wrapper) bool {
  39. //
  40. return false
  41. }
  42. // Called inside goroutine
  43. func (this *Modules) BackEnd(wrap *wrapper.Wrapper) bool {
  44. //
  45. return false
  46. }