package main import ( "io" "os" "github.com/fgm/izidic" "github.com/gin-gonic/gin" "code.osinet.fr/fgm/sqs_demo/services" "code.osinet.fr/fgm/sqs_demo/services/redriver" "code.osinet.fr/fgm/sqs_demo/web" ) func main() { os.Exit(int(main2(os.Stdout, os.Args[0], os.Args[1:]))) } func main2(w io.Writer, name string, args []string) (exitCode byte) { dic := Resolve(w, name, args) h := dic.MustService(services.SvcHttp).(*gin.Engine) addr := dic.MustParam(services.PAddr).(string) if err := h.Run(addr); err != nil { return 1 } return 0 } func Resolve(w io.Writer, name string, args []string) *izidic.Container { dic := izidic.New() dic.Store(services.PName, name) dic.Store(services.PArgs, args) dic.Store(services.PWriter, w) dic.Register(services.SvcClient, services.SQSClientService) dic.Register(services.SvcFlags, services.FlagsService) dic.Register(services.SvcLister, services.ListerService) dic.Register(services.SvcLogger, services.LoggerService) dic.Register(services.SvcProducer, services.ProducerService) dic.Register(services.SvcRedriver, redriver.RedriverService) dic.Register(services.SvcHttp, web.HttpService) dic.MustService(services.SvcFlags) // Store generated params before freeze. dic.Freeze() return dic }