Settings

You can pass application settings when calling New.

  1. func main() {
  2. // Pass Settings creating a new instance
  3. app := fiber.New(&fiber.Settings{
  4. Prefork: true,
  5. CaseSensitive: true,
  6. StrictRouting: true,
  7. ServerHeader: "Fiber",
  8. })
  9.  
  10. // ...
  11.  
  12. app.Listen(3000)
  13. }

Or change the settings after initializing an app.

  1. func main() {
  2. app := fiber.New()
  3.  
  4. // Or change Settings after creating an instance
  5. app.Settings.Prefork = true
  6. app.Settings.CaseSensitive = true
  7. app.Settings.StrictRouting = true
  8. app.Settings.ServerHeader = "Fiber"
  9.  
  10. // ...
  11.  
  12. app.Listen(3000)
  13. }

Settings fields

PropertyTypeDescriptionDefault
PreforkboolEnables use of theSOREUSEPORTsocket option. This will spawn multiple Go processes listening on the same port. learn more about socket sharding.false
ServerHeaderstringEnables the Server HTTP header with the given value.“”
StrictRoutingboolWhen enabled, the router treats /foo and /foo/ as different. Otherwise, the router treats /foo and /foo/ as the same.false
CaseSensitiveboolWhen enabled, /Foo and /foo are different routes. When disabled, /Fooand /foo are treated the same.false
ImmutableboolWhen enabled, all values returned by context methods are immutable. By default they are valid until you return from the handler, see issue #185.false
BodyLimitintSets the maximum allowed size for a request body, if the size exceeds the configured limit, it sends 413 - Request Entity Too Large response.4 1024 1024
ConcurrencyintMaximum number of concurrent connections.256 * 1024
DisableKeepaliveboolDisable keep-alive connections, the server will close incoming connections after sending the first response to clientfalse
DisableDefaultDateboolWhen set to true causes the default date header to be excluded from the response.false
DisableDefaultContentTypeboolWhen set to true, causes the default Content-Type header to be excluded from the Response.false
DisableStartupMessageboolWhen set to true, it will not print out the fiber ASCII and “listening” on messagefalse
ETagboolEnable or disable ETag header generation, since both weak and strong etags are generated using the same hashing method (CRC-32). Weak ETags are the default when enabled.false
TemplateEnginefunc(raw string, bind interface{}) (string, error)You can specify a custom template function to render different template languages. See our Template Middleware **_for presets.nil
TemplateFolderstringA directory for the application’s views. If a directory is set, this will be the prefix for all template paths. c.Render(“home”, data) -> ./views/home.pug“”
TemplateExtensionstringIf you preset the template file extension, you do not need to provide the full filename in the Render function: c.Render(“home”, data) -> home.pug“html”
ReadTimeouttime.DurationThe amount of time allowed to read the full request including body. Default timeout is unlimited.nil
WriteTimeouttime.DurationThe maximum duration before timing out writes of the response. Default timeout is unlimited.nil
IdleTimeouttime.DurationThe maximum amount of time to wait for the next request when keep-alive is enabled. If IdleTimeout is zero, the value of ReadTimeout is used.nil