Skip to content

Commit be2f278

Browse files
authored
Merge pull request #278 from Fenny/master
v1.9.1
2 parents 17e4a0d + a88b589 commit be2f278

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

app.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
// Version of current package
27-
const Version = "1.9.0"
27+
const Version = "1.9.1"
2828

2929
// Map is a shortcut for map[string]interface{}
3030
type Map map[string]interface{}
@@ -50,6 +50,14 @@ type Settings struct {
5050
Immutable bool // default: false
5151
// Max body size that the server accepts
5252
BodyLimit int // default: 4 * 1024 * 1024
53+
// Maximum number of concurrent connections.
54+
Concurrency int // default: 256 * 1024
55+
// Disable keep-alive connections, the server will close incoming connections after sending the first response to client
56+
DisableKeepalive bool // default: false
57+
// When set to true causes the default date header to be excluded from the response.
58+
DisableDefaultDate bool // default: false
59+
// When set to true, causes the default Content-Type header to be excluded from the Response.
60+
DisableDefaultContentType bool // default: false
5361
// Folder containing template files
5462
TemplateFolder string // default: ""
5563
// Template engine: html, amber, handlebars , mustache or pug
@@ -88,9 +96,12 @@ func New(settings ...*Settings) *App {
8896
if !app.Settings.Prefork { // Default to -prefork flag if false
8997
app.Settings.Prefork = isPrefork()
9098
}
91-
if app.Settings.BodyLimit == 0 { // Default MaxRequestBodySize
99+
if app.Settings.BodyLimit <= 0 { // Default MaxRequestBodySize
92100
app.Settings.BodyLimit = 4 * 1024 * 1024
93101
}
102+
if app.Settings.Concurrency <= 0 {
103+
app.Settings.Concurrency = 256 * 1024
104+
}
94105
if app.Settings.Immutable { // Replace unsafe conversion funcs
95106
getString = getStringImmutable
96107
getBytes = getBytesImmutable
@@ -488,6 +499,10 @@ func (app *App) newServer() *fasthttp.Server {
488499
return &fasthttp.Server{
489500
Handler: app.handler,
490501
Name: app.Settings.ServerHeader,
502+
Concurrency: app.Settings.Concurrency,
503+
NoDefaultDate: app.Settings.DisableDefaultDate,
504+
NoDefaultContentType: app.Settings.DisableDefaultContentType,
505+
DisableKeepalive: app.Settings.DisableKeepalive,
491506
MaxRequestBodySize: app.Settings.BodyLimit,
492507
NoDefaultServerHeader: app.Settings.ServerHeader == "",
493508
ReadTimeout: app.Settings.ReadTimeout,

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ go 1.11
55
require (
66
github.com/gorilla/schema v1.1.0
77
github.com/json-iterator/go v1.1.9
8-
github.com/valyala/fasthttp v1.9.0
8+
github.com/valyala/fasthttp v1.11.0
99
)

go.sum

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,19 @@ github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGn
77
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
88
github.com/klauspost/compress v1.8.2 h1:Bx0qjetmNjdFXASH02NSAREKpiaDwkO1DRZ3dV2KCcs=
99
github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
10-
github.com/klauspost/compress v1.10.4 h1:jFzIFaf586tquEB5EhzQG0HwGNSlgAJpG53G6Ss11wc=
11-
github.com/klauspost/compress v1.10.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
1210
github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w=
1311
github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
14-
github.com/klauspost/cpuid v1.2.3/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
1512
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
1613
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
17-
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
18-
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
1914
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
2015
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
21-
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
22-
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
2316
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2417
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
2518
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
2619
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
2720
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
28-
github.com/valyala/fasthttp v1.9.0 h1:hNpmUdy/+ZXYpGy0OBfm7K0UQTzb73W0T0U4iJIVrMw=
29-
github.com/valyala/fasthttp v1.9.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w=
21+
github.com/valyala/fasthttp v1.11.0 h1:CpWaRjWmZMkgcngl8P7ygGoHmfXSZDcKx3Vdv8Bdkuw=
22+
github.com/valyala/fasthttp v1.11.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w=
3023
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
3124
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
3225
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=

0 commit comments

Comments
 (0)