core.go 1.1 KB

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