X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=cmd%2Fbpa-restapi-agent%2Fmain.go;h=26f0ba4e6c1c76ada4415f75bc3652ab28ae55ce;hb=e7e71a03c35316cfc4279f19bcaaca73fea339d0;hp=6a8960b9c7ea583793f7bea9af044492aaa5574a;hpb=5885be79556efc50b6ee9e1c6e51a803095b9073;p=icn.git diff --git a/cmd/bpa-restapi-agent/main.go b/cmd/bpa-restapi-agent/main.go index 6a8960b..26f0ba4 100644 --- a/cmd/bpa-restapi-agent/main.go +++ b/cmd/bpa-restapi-agent/main.go @@ -10,16 +10,16 @@ import ( "os/signal" "time" - //To Do - Implement internal for checking config + "github.com/gorilla/handlers" "bpa-restapi-agent/api" utils "bpa-restapi-agent/internal" + "bpa-restapi-agent/internal/auth" "bpa-restapi-agent/internal/config" ) func main() { - // To Do - Implement initial settings // check initial config err := utils.CheckInitialSettings() if err != nil{ @@ -36,7 +36,6 @@ func main() { // Create custom http server httpServer := &http.Server{ Handler: loggedRouter, - // To Do - Implement config Addr: ":" + config.GetConfiguration().ServicePort, } connectionsClose := make(chan struct{}) @@ -49,6 +48,13 @@ func main() { }() // Start server - log.Fatal(httpServer.ListenAndServe()) - + tlsConfig, err := auth.GetTLSConfig("ca.cert", "server.cert", "server.key") + if err != nil { + log.Println("Error Getting TLS Configuration. Starting without TLS...") + log.Fatal(httpServer.ListenAndServe()) + } else { + httpServer.TLSConfig = tlsConfig + // empty strings because tlsconfig already has this information + err = httpServer.ListenAndServeTLS("", "") + } }