-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (33 loc) · 1010 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"fmt"
"net/http"
"gin-blog/pkg/setting"
"gin-blog/routers"
)
func main() {
/*endless.DefaultReadTimeOut = setting.ReadTimeOut
endless.DefaultWriteTimeOut = setting.WriteTimeOut
endless.DefaultMaxHeaderBytes = 1 << 20
endPoint := fmt.Sprintf(":%d", setting.HTTPPort)
server := endless.NewServer(endPoint, routers.InitRouter())
server.BeforeBegin = func(add string) {
log.Printf("Actual pid is %d", syscall.Getpid())
}
err := server.ListenAndServe()
if err != nil {
log.Printf("Server err: %v", err)
}*/
router := routers.InitRouter()
s := &http.Server{
Addr: fmt.Sprintf(":%d", setting.HTTPPort),
Handler: router,
// 请求的读取操作在超时前的最大持续时间
ReadTimeout: setting.ReadTimeOut,
// 回复的写入操作在超时前的最大持续时间
WriteTimeout: setting.WriteTimeOut,
// 请求的头域最大长度,如为0则用DefaultMaxHeaderBytes 512M
MaxHeaderBytes: 1 << 20,
}
s.ListenAndServe()
}