You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
727 B
23 lines
727 B
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
|
|
}
|
|
}
|
|
|