https
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"ems.agt/lib/dborm"
|
||||
"ems.agt/lib/global"
|
||||
@@ -70,6 +71,14 @@ func HttpListen(addr string, router http.Handler) {
|
||||
}
|
||||
}
|
||||
|
||||
func HttpListenTLS(addr, certFile, keyFile string, router http.Handler) {
|
||||
err := http.ListenAndServeTLS(addr, certFile, keyFile, router)
|
||||
if err != nil {
|
||||
fmt.Println("ListenAndServeTLS err:", err)
|
||||
os.Exit(6)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
conf := config.GetYamlConfig()
|
||||
|
||||
@@ -117,12 +126,21 @@ func main() {
|
||||
// ipv4 goroutines
|
||||
if rest.IPv4 != "" {
|
||||
listen := rest.IPv4 + ":" + strconv.Itoa(int(rest.Port))
|
||||
go HttpListen(listen, router)
|
||||
if strings.ToLower(rest.Schema) == "https" {
|
||||
go HttpListenTLS(listen, rest.CertFile, rest.KeyFile, router)
|
||||
} else {
|
||||
go HttpListen(listen, router)
|
||||
}
|
||||
|
||||
}
|
||||
// ipv6 goroutines
|
||||
if rest.IPv6 != "" {
|
||||
listenv6 := "[" + rest.IPv6 + "]" + ":" + strconv.Itoa(int(rest.Port))
|
||||
go HttpListen(listenv6, router)
|
||||
if strings.ToLower(rest.Schema) == "https" {
|
||||
go HttpListenTLS(listenv6, rest.CertFile, rest.KeyFile, router)
|
||||
} else {
|
||||
go HttpListen(listenv6, router)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user