-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (36 loc) · 825 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
/**
* Created by IDEA.
* User: godsoul
*/
package main
import (
"github.com/gin-gonic/gin"
"github.com/DeanThompson/ginpprof"
"github.com/guobin8205/api_demo/utils/config"
"net/http"
"time"
"github.com/guobin8205/api_demo/routers"
_ "github.com/guobin8205/api_demo/models"
"github.com/guobin8205/api_demo/middleware"
)
func main() {
router := gin.New()
router.Static("/data", "./data")
//middleware
router.Use(gin.Logger())
router.Use(gin.Recovery())
router.Use(middleware.ParseRequest())
if conf.RunMode == "pro" {
gin.SetMode(gin.ReleaseMode)
}
ginpprof.Wrap(router)
routers.SetRouters(router)
s := &http.Server{
Addr: conf.HttpPort,
Handler: router,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,
}
s.ListenAndServe()
}