frontend.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package main
  2. /*
  3. import (
  4. "net/http"
  5. "golang-fave/engine/wrapper"
  6. utils "golang-fave/engine/wrapper/utils"
  7. )
  8. */
  9. /*
  10. type MenuItem struct {
  11. Name string
  12. Link string
  13. Active bool
  14. }
  15. type TmplData struct {
  16. MetaTitle string
  17. MetaKeywords string
  18. MetaDescription string
  19. MenuItems []MenuItem
  20. }
  21. */
  22. /*
  23. func handlerFrontEnd(wrapper *wrapper.Wrapper) bool {
  24. // Redirect to CP, if MySQL config file is not exists
  25. if !utils.IsMySqlConfigExists(wrapper.DirVHostHome) {
  26. (*wrapper.W).Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
  27. http.Redirect(*wrapper.W, wrapper.R, wrapper.R.URL.Scheme+"://"+wrapper.R.Host+"/cp/", 302)
  28. return true
  29. }
  30. // Connect to database
  31. // Else logic here
  32. if wrapper.R.URL.Path == "/" {
  33. return wrapper.TmplFrontEnd("index", nil)
  34. }
  35. if wrapper.R.URL.Path == "/" {
  36. return wrapper.TmplFrontEnd("index", TmplData{
  37. MetaTitle: "Meta Title",
  38. MetaKeywords: "Meta Keywords",
  39. MetaDescription: "Meta Description",
  40. MenuItems: []MenuItem{
  41. {Name: "Home", Link: "/", Active: true},
  42. {Name: "Item 1", Link: "/#1", Active: false},
  43. {Name: "Item 2", Link: "/#2", Active: false},
  44. {Name: "Item 3", Link: "/#3", Active: false},
  45. },
  46. })
  47. }
  48. return false
  49. }
  50. */