main.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/go-nunu/nunu-layout-advanced/cmd/server/wire"
  5. "github.com/go-nunu/nunu-layout-advanced/pkg/config"
  6. "github.com/go-nunu/nunu-layout-advanced/pkg/http"
  7. "github.com/go-nunu/nunu-layout-advanced/pkg/log"
  8. "go.uber.org/zap"
  9. )
  10. // @title Nunu Example API
  11. // @version 1.0.0
  12. // @description This is a sample server celler server.
  13. // @termsOfService http://swagger.io/terms/
  14. // @contact.name API Support
  15. // @contact.url http://www.swagger.io/support
  16. // @contact.email support@swagger.io
  17. // @license.name Apache 2.0
  18. // @license.url http://www.apache.org/licenses/LICENSE-2.0.html
  19. // @host localhost:8000
  20. // @BasePath /
  21. // @securityDefinitions.apiKey Bearer
  22. // @in header
  23. // @name Authorization
  24. // @externalDocs.description OpenAPI
  25. // @externalDocs.url https://swagger.io/resources/open-api/
  26. func main() {
  27. conf := config.NewConfig()
  28. logger := log.NewLog(conf)
  29. servers, cleanup, err := wire.NewApp(conf, logger)
  30. if err != nil {
  31. panic(err)
  32. }
  33. logger.Info("server start", zap.String("host", "http://localhost:"+conf.GetString("http.port")))
  34. logger.Info("docs addr", zap.String("addr", fmt.Sprintf("http://127.0.0.1:%d/swagger/index.html", conf.GetInt("http.port"))))
  35. //go grpc.Run(servers.ServerGRPC, conf)
  36. http.Run(servers.ServerHTTP, fmt.Sprintf(":%d", conf.GetInt("http.port")))
  37. defer cleanup()
  38. }