mirror of
https://github.com/gofiber/fiber.git
synced 2025-02-23 09:04:23 +00:00
commit
be2f278f6e
19
app.go
19
app.go
@ -24,7 +24,7 @@ import (
|
||||
)
|
||||
|
||||
// Version of current package
|
||||
const Version = "1.9.0"
|
||||
const Version = "1.9.1"
|
||||
|
||||
// Map is a shortcut for map[string]interface{}
|
||||
type Map map[string]interface{}
|
||||
@ -50,6 +50,14 @@ type Settings struct {
|
||||
Immutable bool // default: false
|
||||
// Max body size that the server accepts
|
||||
BodyLimit int // default: 4 * 1024 * 1024
|
||||
// Maximum number of concurrent connections.
|
||||
Concurrency int // default: 256 * 1024
|
||||
// Disable keep-alive connections, the server will close incoming connections after sending the first response to client
|
||||
DisableKeepalive bool // default: false
|
||||
// When set to true causes the default date header to be excluded from the response.
|
||||
DisableDefaultDate bool // default: false
|
||||
// When set to true, causes the default Content-Type header to be excluded from the Response.
|
||||
DisableDefaultContentType bool // default: false
|
||||
// Folder containing template files
|
||||
TemplateFolder string // default: ""
|
||||
// Template engine: html, amber, handlebars , mustache or pug
|
||||
@ -88,9 +96,12 @@ func New(settings ...*Settings) *App {
|
||||
if !app.Settings.Prefork { // Default to -prefork flag if false
|
||||
app.Settings.Prefork = isPrefork()
|
||||
}
|
||||
if app.Settings.BodyLimit == 0 { // Default MaxRequestBodySize
|
||||
if app.Settings.BodyLimit <= 0 { // Default MaxRequestBodySize
|
||||
app.Settings.BodyLimit = 4 * 1024 * 1024
|
||||
}
|
||||
if app.Settings.Concurrency <= 0 {
|
||||
app.Settings.Concurrency = 256 * 1024
|
||||
}
|
||||
if app.Settings.Immutable { // Replace unsafe conversion funcs
|
||||
getString = getStringImmutable
|
||||
getBytes = getBytesImmutable
|
||||
@ -488,6 +499,10 @@ func (app *App) newServer() *fasthttp.Server {
|
||||
return &fasthttp.Server{
|
||||
Handler: app.handler,
|
||||
Name: app.Settings.ServerHeader,
|
||||
Concurrency: app.Settings.Concurrency,
|
||||
NoDefaultDate: app.Settings.DisableDefaultDate,
|
||||
NoDefaultContentType: app.Settings.DisableDefaultContentType,
|
||||
DisableKeepalive: app.Settings.DisableKeepalive,
|
||||
MaxRequestBodySize: app.Settings.BodyLimit,
|
||||
NoDefaultServerHeader: app.Settings.ServerHeader == "",
|
||||
ReadTimeout: app.Settings.ReadTimeout,
|
||||
|
2
go.mod
2
go.mod
@ -5,5 +5,5 @@ go 1.11
|
||||
require (
|
||||
github.com/gorilla/schema v1.1.0
|
||||
github.com/json-iterator/go v1.1.9
|
||||
github.com/valyala/fasthttp v1.9.0
|
||||
github.com/valyala/fasthttp v1.11.0
|
||||
)
|
||||
|
11
go.sum
11
go.sum
@ -7,26 +7,19 @@ github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGn
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/klauspost/compress v1.8.2 h1:Bx0qjetmNjdFXASH02NSAREKpiaDwkO1DRZ3dV2KCcs=
|
||||
github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
||||
github.com/klauspost/compress v1.10.4 h1:jFzIFaf586tquEB5EhzQG0HwGNSlgAJpG53G6Ss11wc=
|
||||
github.com/klauspost/compress v1.10.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||
github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w=
|
||||
github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||
github.com/klauspost/cpuid v1.2.3/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasthttp v1.9.0 h1:hNpmUdy/+ZXYpGy0OBfm7K0UQTzb73W0T0U4iJIVrMw=
|
||||
github.com/valyala/fasthttp v1.9.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w=
|
||||
github.com/valyala/fasthttp v1.11.0 h1:CpWaRjWmZMkgcngl8P7ygGoHmfXSZDcKx3Vdv8Bdkuw=
|
||||
github.com/valyala/fasthttp v1.11.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w=
|
||||
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
|
Loading…
x
Reference in New Issue
Block a user