wechat.go 986 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // wechat
  2. //
  3. // Description: wechat service
  4. //
  5. // Schemes: http, https
  6. // Host: localhost:0
  7. // BasePath: /
  8. // Version: 0.0.1
  9. // SecurityDefinitions:
  10. // Token:
  11. // type: apiKey
  12. // name: Authorization
  13. // in: header
  14. // Security:
  15. // - Token: []
  16. // Consumes:
  17. // - application/json
  18. //
  19. // Produces:
  20. // - application/json
  21. //
  22. // swagger:meta
  23. package main
  24. import (
  25. "flag"
  26. "fmt"
  27. "wechat-api/internal/config"
  28. "wechat-api/internal/handler"
  29. "wechat-api/internal/svc"
  30. "github.com/zeromicro/go-zero/core/conf"
  31. "github.com/zeromicro/go-zero/rest"
  32. )
  33. var configFile = flag.String("f", "etc/wechat.yaml", "the config file")
  34. func main() {
  35. flag.Parse()
  36. var c config.Config
  37. conf.MustLoad(*configFile, &c, conf.UseEnv())
  38. server := rest.MustNewServer(c.RestConf, rest.WithCors(c.CROSConf.Address))
  39. defer server.Stop()
  40. ctx := svc.NewServiceContext(c)
  41. handler.RegisterHandlers(server, ctx)
  42. fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
  43. server.Start()
  44. }