module_some.go 918 B

123456789101112131415161718192021222324252627282930
  1. package modules
  2. import (
  3. "fmt"
  4. "net/http"
  5. "golang-fave/engine/wrapper"
  6. )
  7. func (this *Modules) RegisterModule_Some() *Module {
  8. return this.newModule(MInfo{
  9. WantDB: true,
  10. Mount: "some",
  11. Name: "Some Module",
  12. }, func(wrap *wrapper.Wrapper) {
  13. // Front-end
  14. fmt.Printf("SOME FrontEnd func call\n")
  15. wrap.W.WriteHeader(http.StatusOK)
  16. wrap.W.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
  17. wrap.W.Header().Set("Content-Type", "text/html; charset=utf-8")
  18. wrap.W.Write([]byte(`SOME FrontEnd func call (` + wrap.CurrModule + `)`))
  19. }, func(wrap *wrapper.Wrapper) {
  20. // Back-end
  21. fmt.Printf("SOME BackEnd func call\n")
  22. wrap.W.WriteHeader(http.StatusOK)
  23. wrap.W.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
  24. wrap.W.Header().Set("Content-Type", "text/html; charset=utf-8")
  25. wrap.W.Write([]byte(`SOME BackEnd func call (` + wrap.CurrModule + `)`))
  26. })
  27. }