自定义HTTP配置

func main() {

	router := gin.Default()
	// 方式一
	//http.ListenAndServe(":8080", router)

	// 方式二
	s := &http.Server{
		Addr:           ":8080",
		Handler:        router,
		ReadTimeout:    10 * time.Second,
		WriteTimeout:   10 * time.Second,
		MaxHeaderBytes: 1 << 20,
	}
	s.ListenAndServe()
}

  

原文地址:https://www.cnblogs.com/yzg-14/p/13150072.html