Add ReadTimeout to Settings

pull/6/head
Fenny 2020-01-08 23:41:41 +01:00
parent d4f81a5a20
commit 435d4b78ef
2 changed files with 14 additions and 3 deletions

View File

@ -56,6 +56,14 @@ app.ReadBufferSize = 4096
// Per-connection buffer size for responses' writing.
app.WriteBufferSize = 4096
// ReadTimeout is the amount of time allowed to read
// the full request including body. The connection's read
// deadline is reset when the connection opens, or for
// keep-alive connections after the first byte has been read.
//
// By default request read timeout is unlimited.
app.ReadTimeout = 0
// WriteTimeout is the maximum duration before timing out
// writes of the response. It is reset after the request handler
// has returned.

View File

@ -16,11 +16,11 @@ import (
)
const (
Version = "v0.2.0"
Version = `v0.3.0`
banner = ` _____ _ _
| __|_| |_ ___ ___
| __| | . | -_| _|
|__| |_|___|___|_|%s
|__| |_|___|___|_|%s %s
`
)
@ -46,6 +46,7 @@ type Settings struct {
DisableKeepAlive bool
ReadBufferSize int
WriteBufferSize int
ReadTimeout time.Duration
WriteTimeout time.Duration
IdleTimeout time.Duration
MaxConnsPerIP int
@ -84,6 +85,7 @@ func New() *Fiber {
ReadBufferSize: 4096,
WriteBufferSize: 4096,
WriteTimeout: 0,
ReadTimeout: 0,
IdleTimeout: 0,
MaxConnsPerIP: 0,
MaxRequestsPerConn: 0,
@ -322,6 +324,7 @@ func (r *Fiber) Listen(args ...interface{}) {
DisableKeepalive: r.Settings.DisableKeepAlive,
ReadBufferSize: r.Settings.ReadBufferSize,
WriteBufferSize: r.Settings.WriteBufferSize,
ReadTimeout: r.Settings.ReadTimeout,
WriteTimeout: r.Settings.WriteTimeout,
IdleTimeout: r.Settings.IdleTimeout,
MaxConnsPerIP: r.Settings.MaxConnsPerIP,
@ -350,7 +353,7 @@ func (r *Fiber) Listen(args ...interface{}) {
cmd.Run()
}
if !r.Settings.HideBanner {
fmt.Printf(color.HiCyanString(banner), color.GreenString(":"+port))
fmt.Printf(color.HiCyanString(banner), color.GreenString(":"+port), color.HiBlackString("("+Version+")"))
}
// fmt.Printf(banner, Version)
if r.Settings.TLSEnable {