chore: add RunTLS
This commit is contained in:
parent
953ac9d5b9
commit
9ca9fc4632
19
websrvr.go
19
websrvr.go
@ -69,7 +69,6 @@ func run_web(cfg *cfg.Config,users *UsersAccounts,mdlsUsrs map[string]ModelUser,
|
||||
// // AllowOriginFunc: func(origin string) bool {
|
||||
// // return origin == "https://github.com"
|
||||
// // },
|
||||
// MaxAge: 12 * time.Hour,
|
||||
}
|
||||
// corsConfig := cors.DefaultConfig()
|
||||
// corsConfig.AllowAllOrigins = []string{"http://localhost:3333'"}
|
||||
@ -82,10 +81,7 @@ func run_web(cfg *cfg.Config,users *UsersAccounts,mdlsUsrs map[string]ModelUser,
|
||||
corsConfig.AllowOrigins = cfg.AllowOrigins // []string{"http://localhost:3333"},
|
||||
router.Use(cors.New(corsConfig))
|
||||
|
||||
//fmt.Printf("cfg AllowOrigin: %v\n", cfg.AllowOrigins)
|
||||
//db["jesus"] = "DONE"
|
||||
// listTemplates := getFileMatch(cfg.TemplatesRoot,cfg.TemplatesExt)
|
||||
//fmt.Printf("templates list: %v\n", listTemplates)
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"run": "run_web",
|
||||
}).Info(fmt.Sprintf("templates path: %v\n", cfg.TemplatesFiles))
|
||||
@ -110,13 +106,6 @@ func run_web(cfg *cfg.Config,users *UsersAccounts,mdlsUsrs map[string]ModelUser,
|
||||
// ))
|
||||
// apply i18n middleware
|
||||
|
||||
// router.Use(func(c *gin.Context) {
|
||||
// c.Set("cfg",cfg)
|
||||
// // c.String(http.StatusNotFound, "Requested url does not exist")
|
||||
// //c.Abort()
|
||||
// c.Next()
|
||||
// })
|
||||
|
||||
// router.StaticFS("/public", http.FS(f))
|
||||
router.Static(cfg.AssetsURL,cfg.AssetsPath)
|
||||
var store interface{}
|
||||
@ -137,7 +126,11 @@ func run_web(cfg *cfg.Config,users *UsersAccounts,mdlsUsrs map[string]ModelUser,
|
||||
browser.OpenURL(fmt.Sprintf(runFlags.url))
|
||||
}
|
||||
}
|
||||
err = router.Run(hostport)
|
||||
if cfg.Protocol == "https" {
|
||||
err = router.RunTLS(hostport, cfg.CertPem, cfg.KeyPem)
|
||||
} else {
|
||||
err = router.Run(hostport)
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatalf("Error run webserver: %v", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user