shorturl.go 523 B

12345678910111213141516171819202122232425262728
  1. package main
  2. import (
  3. "flag"
  4. "shorturl/api/internal/config"
  5. "shorturl/api/internal/handler"
  6. "shorturl/api/internal/svc"
  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/shorturl-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. }