@@ -130,90 +130,40 @@ type App struct {
130
130
}
131
131
132
132
// Config is a struct holding the server settings.
133
- type Config struct {
134
- // Views is the interface that wraps the Render function.
135
- //
136
- // Default: nil
137
- Views Views `json:"-"`
138
-
139
- // If you want to validate header/form/query... automatically when to bind, you can define struct validator.
140
- // Fiber doesn't have default validator, so it'll skip validator step if you don't use any validator.
141
- //
142
- // Default: nil
143
- StructValidator StructValidator
144
-
145
- // CompressedFileSuffixes adds suffix to the original file name and
146
- // tries saving the resulting compressed file under the new file name.
147
- //
148
- // Default: map[string]string{"gzip": ".fiber.gz", "br": ".fiber.br", "zstd": ".fiber.zst"}
149
- CompressedFileSuffixes map [string ]string `json:"compressed_file_suffixes"`
150
-
151
- // ErrorHandler is executed when an error is returned from fiber.Handler.
152
- //
153
- // Default: DefaultErrorHandler
154
- ErrorHandler ErrorHandler `json:"-"`
155
-
156
- // When set by an external client of Fiber it will use the provided implementation of a
157
- // JSONMarshal
158
- //
159
- // Allowing for flexibility in using another json library for encoding
160
- // Default: json.Marshal
161
- JSONEncoder utils.JSONMarshal `json:"-"`
162
-
163
- // When set by an external client of Fiber it will use the provided implementation of a
164
- // JSONUnmarshal
165
- //
166
- // Allowing for flexibility in using another json library for decoding
167
- // Default: json.Unmarshal
168
- JSONDecoder utils.JSONUnmarshal `json:"-"`
169
-
170
- // XMLEncoder set by an external client of Fiber it will use the provided implementation of a
171
- // XMLMarshal
172
- //
173
- // Allowing for flexibility in using another XML library for encoding
174
- // Default: xml.Marshal
175
- XMLEncoder utils.XMLMarshal `json:"-"`
176
-
177
- trustedProxiesMap map [string ]struct {}
178
-
179
- // You can define custom color scheme. They'll be used for startup message, route list and some middlewares.
180
- //
181
- // Optional. Default: DefaultColors
182
- ColorScheme Colors `json:"color_scheme"`
183
-
133
+ type Config struct { //nolint:govet // Aligning the struct fields is not necessary. betteralign:ignore
184
134
// Enables the "Server: value" HTTP header.
185
135
//
186
136
// Default: ""
187
137
ServerHeader string `json:"server_header"`
188
138
189
- // Views Layout is the global layout for all template render until override on Render function.
190
- //
191
- // Default: ""
192
- ViewsLayout string `json:"views_layout"`
193
-
194
- // ProxyHeader will enable c.IP() to return the value of the given header key
195
- // By default c.IP() will return the Remote IP from the TCP connection
196
- // This property can be useful if you are behind a load balancer: X-Forwarded-*
197
- // NOTE: headers are easily spoofed and the detected IP addresses are unreliable.
139
+ // When set to true, the router treats "/foo" and "/foo/" as different.
140
+ // By default this is disabled and both "/foo" and "/foo/" will execute the same handler.
198
141
//
199
- // Default: ""
200
- ProxyHeader string `json:"proxy_header "`
142
+ // Default: false
143
+ StrictRouting bool `json:"strict_routing "`
201
144
202
- // This function allows to setup app name for the app
145
+ // When set to true, enables case sensitive routing.
146
+ // E.g. "/FoO" and "/foo" are treated as different routes.
147
+ // By default this is disabled and both "/FoO" and "/foo" will execute the same handler.
203
148
//
204
- // Default: nil
205
- AppName string `json:"app_name "`
149
+ // Default: false
150
+ CaseSensitive bool `json:"case_sensitive "`
206
151
207
- // Read EnableTrustedProxyCheck doc.
152
+ // When set to true, this relinquishes the 0-allocation promise in certain
153
+ // cases in order to access the handler values (e.g. request bodies) in an
154
+ // immutable fashion so that these values are available even if you return
155
+ // from handler.
208
156
//
209
- // Default: []string
210
- TrustedProxies []string `json:"trusted_proxies"`
211
- trustedProxyRanges []* net.IPNet
157
+ // Default: false
158
+ Immutable bool `json:"immutable"`
212
159
213
- // RequestMethods provides customizibility for HTTP methods. You can add/remove methods as you wish.
160
+ // When set to true, converts all encoded characters in the route back
161
+ // before setting the path for the context, so that the routing,
162
+ // the returning of the current url from the context `ctx.Path()`
163
+ // and the parameters `ctx.Params(%key%)` with decoded characters will work
214
164
//
215
- // Optional. Default: DefaultMethods
216
- RequestMethods [] string
165
+ // Default: false
166
+ UnescapePath bool `json:"unescape_path"`
217
167
218
168
// Max body size that the server accepts.
219
169
// -1 will decline any body size
@@ -226,6 +176,21 @@ type Config struct {
226
176
// Default: 256 * 1024
227
177
Concurrency int `json:"concurrency"`
228
178
179
+ // Views is the interface that wraps the Render function.
180
+ //
181
+ // Default: nil
182
+ Views Views `json:"-"`
183
+
184
+ // Views Layout is the global layout for all template render until override on Render function.
185
+ //
186
+ // Default: ""
187
+ ViewsLayout string `json:"views_layout"`
188
+
189
+ // PassLocalsToViews Enables passing of the locals set on a fiber.Ctx to the template engine
190
+ //
191
+ // Default: false
192
+ PassLocalsToViews bool `json:"pass_locals_to_views"`
193
+
229
194
// The amount of time allowed to read the full request including body.
230
195
// It is reset after the request handler has returned.
231
196
// The connection's read deadline is reset when the connection opens.
@@ -258,39 +223,19 @@ type Config struct {
258
223
// Default: 4096
259
224
WriteBufferSize int `json:"write_buffer_size"`
260
225
261
- // When set to true, the router treats "/foo" and "/foo/" as different.
262
- // By default this is disabled and both "/foo" and "/foo/" will execute the same handler.
263
- //
264
- // Default: false
265
- StrictRouting bool `json:"strict_routing"`
266
-
267
- // When set to true, enables case sensitive routing.
268
- // E.g. "/FoO" and "/foo" are treated as different routes.
269
- // By default this is disabled and both "/FoO" and "/foo" will execute the same handler.
270
- //
271
- // Default: false
272
- CaseSensitive bool `json:"case_sensitive"`
273
-
274
- // When set to true, this relinquishes the 0-allocation promise in certain
275
- // cases in order to access the handler values (e.g. request bodies) in an
276
- // immutable fashion so that these values are available even if you return
277
- // from handler.
278
- //
279
- // Default: false
280
- Immutable bool `json:"immutable"`
281
-
282
- // When set to true, converts all encoded characters in the route back
283
- // before setting the path for the context, so that the routing,
284
- // the returning of the current url from the context `ctx.Path()`
285
- // and the parameters `ctx.Params(%key%)` with decoded characters will work
226
+ // CompressedFileSuffixes adds suffix to the original file name and
227
+ // tries saving the resulting compressed file under the new file name.
286
228
//
287
- // Default: false
288
- UnescapePath bool `json:"unescape_path "`
229
+ // Default: map[string]string{"gzip": ".fiber.gz", "br": ".fiber.br", "zstd": ".fiber.zst"}
230
+ CompressedFileSuffixes map [ string ] string `json:"compressed_file_suffixes "`
289
231
290
- // PassLocalsToViews Enables passing of the locals set on a fiber.Ctx to the template engine
232
+ // ProxyHeader will enable c.IP() to return the value of the given header key
233
+ // By default c.IP() will return the Remote IP from the TCP connection
234
+ // This property can be useful if you are behind a load balancer: X-Forwarded-*
235
+ // NOTE: headers are easily spoofed and the detected IP addresses are unreliable.
291
236
//
292
- // Default: false
293
- PassLocalsToViews bool `json:"pass_locals_to_views "`
237
+ // Default: ""
238
+ ProxyHeader string `json:"proxy_header "`
294
239
295
240
// GETOnly rejects all non-GET requests if set to true.
296
241
// This option is useful as anti-DoS protection for servers
@@ -300,6 +245,11 @@ type Config struct {
300
245
// Default: false
301
246
GETOnly bool `json:"get_only"`
302
247
248
+ // ErrorHandler is executed when an error is returned from fiber.Handler.
249
+ //
250
+ // Default: DefaultErrorHandler
251
+ ErrorHandler ErrorHandler `json:"-"`
252
+
303
253
// When set to true, disables keep-alive connections.
304
254
// The server will close incoming connections after sending the first response to client.
305
255
//
@@ -322,6 +272,11 @@ type Config struct {
322
272
// Default: false
323
273
DisableHeaderNormalizing bool `json:"disable_header_normalizing"`
324
274
275
+ // This function allows to setup app name for the app
276
+ //
277
+ // Default: nil
278
+ AppName string `json:"app_name"`
279
+
325
280
// StreamRequestBody enables request body streaming,
326
281
// and calls the handler sooner when given body is
327
282
// larger than the current limit.
@@ -349,6 +304,27 @@ type Config struct {
349
304
// Default: false
350
305
ReduceMemoryUsage bool `json:"reduce_memory_usage"`
351
306
307
+ // When set by an external client of Fiber it will use the provided implementation of a
308
+ // JSONMarshal
309
+ //
310
+ // Allowing for flexibility in using another json library for encoding
311
+ // Default: json.Marshal
312
+ JSONEncoder utils.JSONMarshal `json:"-"`
313
+
314
+ // When set by an external client of Fiber it will use the provided implementation of a
315
+ // JSONUnmarshal
316
+ //
317
+ // Allowing for flexibility in using another json library for decoding
318
+ // Default: json.Unmarshal
319
+ JSONDecoder utils.JSONUnmarshal `json:"-"`
320
+
321
+ // XMLEncoder set by an external client of Fiber it will use the provided implementation of a
322
+ // XMLMarshal
323
+ //
324
+ // Allowing for flexibility in using another XML library for encoding
325
+ // Default: xml.Marshal
326
+ XMLEncoder utils.XMLMarshal `json:"-"`
327
+
352
328
// If you find yourself behind some sort of proxy, like a load balancer,
353
329
// then certain header information may be sent to you using special X-Forwarded-* headers or the Forwarded header.
354
330
// For example, the Host HTTP header is usually used to return the requested host.
@@ -371,13 +347,36 @@ type Config struct {
371
347
// Default: false
372
348
EnableTrustedProxyCheck bool `json:"enable_trusted_proxy_check"`
373
349
350
+ // Read EnableTrustedProxyCheck doc.
351
+ //
352
+ // Default: []string
353
+ TrustedProxies []string `json:"trusted_proxies"`
354
+ trustedProxiesMap map [string ]struct {}
355
+ trustedProxyRanges []* net.IPNet
356
+
374
357
// If set to true, c.IP() and c.IPs() will validate IP addresses before returning them.
375
358
// Also, c.IP() will return only the first valid IP rather than just the raw header
376
359
// WARNING: this has a performance cost associated with it.
377
360
//
378
361
// Default: false
379
362
EnableIPValidation bool `json:"enable_ip_validation"`
380
363
364
+ // You can define custom color scheme. They'll be used for startup message, route list and some middlewares.
365
+ //
366
+ // Optional. Default: DefaultColors
367
+ ColorScheme Colors `json:"color_scheme"`
368
+
369
+ // If you want to validate header/form/query... automatically when to bind, you can define struct validator.
370
+ // Fiber doesn't have default validator, so it'll skip validator step if you don't use any validator.
371
+ //
372
+ // Default: nil
373
+ StructValidator StructValidator
374
+
375
+ // RequestMethods provides customizibility for HTTP methods. You can add/remove methods as you wish.
376
+ //
377
+ // Optional. Default: DefaultMethods
378
+ RequestMethods []string
379
+
381
380
// EnableSplittingOnParsers splits the query/body/header parameters by comma when it's true.
382
381
// For example, you can use it to parse multiple values from a query parameter like this:
383
382
// /api?foo=bar,baz == foo[]=bar&foo[]=baz
0 commit comments