13 //To Do - Implement internal for checking config
14 "github.com/gorilla/handlers"
16 "bpa-restapi-agent/api"
17 utils "bpa-restapi-agent/internal"
18 "bpa-restapi-agent/internal/config"
22 // To Do - Implement initial settings
23 // check initial config
24 err := utils.CheckInitialSettings()
29 rand.Seed(time.Now().UnixNano())
31 httpRouter := api.NewRouter(nil, nil, nil)
32 // Return http.handler and log requests to Stdout
33 loggedRouter := handlers.LoggingHandler(os.Stdout, httpRouter)
34 log.Println("Starting Integrated Cloud Native API")
36 // Create custom http server
37 httpServer := &http.Server{
38 Handler: loggedRouter,
39 // To Do - Implement config
40 Addr: ":" + config.GetConfiguration().ServicePort,
42 connectionsClose := make(chan struct{})
44 c := make(chan os.Signal, 1) // create c channel to receive notifications
45 signal.Notify(c, os.Interrupt) // register c channel to run concurrently
47 httpServer.Shutdown(context.Background())
48 close(connectionsClose)
52 log.Fatal(httpServer.ListenAndServe())