mirror of
https://github.com/Jinnrry/PMail.git
synced 2025-11-01 12:22:38 +08:00
v2.0
This commit is contained in:
35
server/http_server/http_server.go
Normal file
35
server/http_server/http_server.go
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user