add ssl support for web
This commit is contained in:
parent
75db79b4b6
commit
493b0c5ac2
4 changed files with 118 additions and 7 deletions
18
web.go
18
web.go
|
@ -169,12 +169,22 @@ func runWeb(*cli.Context) {
|
|||
// Not found handler.
|
||||
m.NotFound(routers.NotFound)
|
||||
|
||||
protocol := base.Cfg.MustValue("server", "PROTOCOL", "http")
|
||||
listenAddr := fmt.Sprintf("%s:%s",
|
||||
base.Cfg.MustValue("server", "HTTP_ADDR"),
|
||||
base.Cfg.MustValue("server", "HTTP_PORT", "3000"))
|
||||
log.Info("Listen: %s", listenAddr)
|
||||
if err := http.ListenAndServe(listenAddr, m); err != nil {
|
||||
fmt.Println(err.Error())
|
||||
//log.Critical(err.Error()) // not working now
|
||||
|
||||
if protocol == "http" {
|
||||
log.Info("Listen: http://%s", listenAddr)
|
||||
if err := http.ListenAndServe(listenAddr, m); err != nil {
|
||||
fmt.Println(err.Error())
|
||||
//log.Critical(err.Error()) // not working now
|
||||
}
|
||||
} else if protocol == "https" {
|
||||
log.Info("Listen: https://%s", listenAddr)
|
||||
if err := http.ListenAndServeTLS(listenAddr, base.Cfg.MustValue("server", "CERT_FILE"),
|
||||
base.Cfg.MustValue("server", "KEY_FILE"), m); err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue