Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
laodaming 2023-08-21 18:01:18 +08:00
commit 29dedd407d

View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"crypto/tls"
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
@ -41,6 +42,8 @@ func SetCors(w http.ResponseWriter, r *http.Request) {
var pathdict sync.Map = sync.Map{} var pathdict sync.Map = sync.Map{}
func main() { func main() {
log.SetFlags(log.Llongfile)
// 将静态资源路径存储到pathdict // 将静态资源路径存储到pathdict
pathdict.Store("/css", true) pathdict.Store("/css", true)
pathdict.Store("/fonts", true) pathdict.Store("/fonts", true)
@ -114,7 +117,34 @@ func main() {
ServerAddress := ":9900" ServerAddress := ":9900"
log.Println("listen on ", ServerAddress) log.Println("listen on ", ServerAddress)
log.Fatal(http.ListenAndServe(ServerAddress, mux))
keydata, err := os.ReadFile("/opt/server.fusen.3718.cn.key")
if err != nil {
panic(err)
}
pemdata, err := os.ReadFile("/opt/server.fusen.3718.cn.pem")
if err != nil {
panic(err)
}
cert, err := tls.X509KeyPair(pemdata, keydata)
if err != nil {
panic(err)
}
tlscfg := &tls.Config{
Certificates: []tls.Certificate{cert},
MinVersion: tls.VersionTLS12,
MaxVersion: tls.VersionTLS13,
}
serv := http.Server{
Addr: ServerAddress,
Handler: mux,
TLSConfig: tlscfg,
}
log.Fatal(serv.ListenAndServeTLS("", ""))
} }
// 后端服务的类型 // 后端服务的类型