Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
commit
29dedd407d
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
@ -41,6 +42,8 @@ func SetCors(w http.ResponseWriter, r *http.Request) {
|
|||
var pathdict sync.Map = sync.Map{}
|
||||
|
||||
func main() {
|
||||
log.SetFlags(log.Llongfile)
|
||||
|
||||
// 将静态资源路径存储到pathdict
|
||||
pathdict.Store("/css", true)
|
||||
pathdict.Store("/fonts", true)
|
||||
|
@ -114,7 +117,34 @@ func main() {
|
|||
|
||||
ServerAddress := ":9900"
|
||||
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("", ""))
|
||||
}
|
||||
|
||||
// 后端服务的类型
|
||||
|
|
Loading…
Reference in New Issue
Block a user