install.go 822 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package install
  2. import (
  3. "net/http"
  4. "runtime"
  5. "github.com/xinliangnote/go-gin-api/configs"
  6. "github.com/xinliangnote/go-gin-api/internal/pkg/core"
  7. "github.com/xinliangnote/go-gin-api/pkg/file"
  8. "go.uber.org/zap"
  9. )
  10. type handler struct {
  11. logger *zap.Logger
  12. }
  13. func New(logger *zap.Logger) *handler {
  14. return &handler{
  15. logger: logger,
  16. }
  17. }
  18. func (h *handler) View() core.HandlerFunc {
  19. type viewResponse struct {
  20. Config configs.Config
  21. MinGoVersion float64
  22. GoVersion string
  23. }
  24. return func(ctx core.Context) {
  25. if _, ok := file.IsExists(configs.ProjectInstallMark); ok {
  26. ctx.Redirect(http.StatusTemporaryRedirect, "/")
  27. }
  28. obj := new(viewResponse)
  29. obj.Config = configs.Get()
  30. obj.MinGoVersion = configs.MinGoVersion
  31. obj.GoVersion = runtime.Version()
  32. ctx.HTML("install_view", obj)
  33. }
  34. }