Smail/server/http_server/http_server.go
2023-08-12 12:49:57 +08:00

36 lines
585 B
Go

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)
}
}