gin中自定义http的配置
package main import ( "github.com/gin-gonic/gin" "net/http" "time" ) func main() { // 自定义http配置1 //router := gin.Default() //router.GET("/", func(context *gin.Context) { // context.String(200, "OK") //}) //http.ListenAndServe(":3000", router) // 自定义http配置2 r := gin.Default() r.GET("/", func(context *gin.Context) { context.String(200, "ok") }) s := &http.Server{ Addr: ":4000", Handler: r, ReadTimeout: 10 * time.Second, WriteTimeout: 10 * time.Second, MaxHeaderBytes: 1 << 20, // 1M } s.ListenAndServe() }