This commit is contained in:
jinnrry
2023-08-12 10:09:22 +08:00
parent 4a26f52fde
commit 318fea24ad
42 changed files with 890 additions and 375 deletions

View File

@@ -0,0 +1,35 @@
package http_server
import (
"fmt"
"net/http"
"pmail/controllers"
"time"
)
const HttpPort = 80
// 这个服务是为了拦截http请求转发到https
var httpServer *http.Server
func HttpStop() {
if httpServer != nil {
httpServer.Close()
}
}
func HttpStart() {
mux := http.NewServeMux()
mux.HandleFunc("/", controllers.Interceptor)
httpServer = &http.Server{
Addr: fmt.Sprintf(":%d", HttpPort),
Handler: mux,
ReadTimeout: time.Second * 60,
WriteTimeout: time.Second * 60,
}
err := httpServer.ListenAndServe()
if err != nil {
panic(err)
}
}