bookstore.go 526 B

123456789101112131415161718192021222324252627
  1. package main
  2. import (
  3. "bookstore/api/internal/config"
  4. "bookstore/api/internal/handler"
  5. "bookstore/api/internal/svc"
  6. "flag"
  7. "github.com/tal-tech/go-zero/core/conf"
  8. "github.com/tal-tech/go-zero/rest"
  9. )
  10. var configFile = flag.String("f", "etc/bookstore-api.yaml", "the config file")
  11. func main() {
  12. flag.Parse()
  13. var c config.Config
  14. conf.MustLoad(*configFile, &c)
  15. ctx := svc.NewServiceContext(c)
  16. server := rest.MustNewServer(c.RestConf)
  17. defer server.Stop()
  18. handler.RegisterHandlers(server, ctx)
  19. server.Start()
  20. }