package app import ( "net/http" "time" "github.com/gin-gonic/gin" ) type server interface { ListenAndServe() error } // 设置服务启动 func InitServer(port string, handler *gin.Engine) server { return &http.Server{ Addr: port, //监听的TCP地址,如果为空字符串会使用":http" Handler: handler, //调用的处理器,如为nil会调用http.DefaultServeMux ReadTimeout: 3600 * time.Second, //请求的读取操作在超时前的最大持续时间 WriteTimeout: 3600 * time.Second, //回复的写入操作在超时前的最大持续时间 MaxHeaderBytes: 1 << 60, //请求的头域最大长度,如为0则用DefaultMaxHeaderBytes } }