@@ -7,7 +7,6 @@ package fiber
7
7
import (
8
8
"bufio"
9
9
"crypto/tls"
10
- "flag"
11
10
"fmt"
12
11
"io/ioutil"
13
12
"log"
@@ -26,7 +25,7 @@ import (
26
25
)
27
26
28
27
// Version of Fiber
29
- const Version = "1.8.2 "
28
+ const Version = "1.8.3 "
30
29
31
30
type (
32
31
// App denotes the Fiber application.
51
50
ServerHeader string `default:""`
52
51
// Enables handler values to be immutable even if you return from handler
53
52
Immutable bool `default:"false"`
53
+ // Deprecated v1.8.2
54
54
// Enables GZip / Deflate compression for all responses
55
55
Compression bool `default:"false"`
56
56
// Max body size that the server accepts
@@ -64,11 +64,6 @@ type (
64
64
}
65
65
)
66
66
67
- func init () {
68
- flag .Bool ("prefork" , false , "Use prefork" )
69
- flag .Bool ("child" , false , "Is a child process" )
70
- }
71
-
72
67
// New : https://fiber.wiki/application#new
73
68
func New (settings ... * Settings ) * App {
74
69
var prefork , child bool
@@ -90,17 +85,21 @@ func New(settings ...*Settings) *App {
90
85
}
91
86
// If settings exist, set some defaults
92
87
if len (settings ) > 0 {
93
- if ! settings [0 ].Prefork { // Default to -prefork flag if false
94
- settings [0 ].Prefork = prefork
88
+ app .Settings = settings [0 ] // Set custom settings
89
+ if ! app .Settings .Prefork { // Default to -prefork flag if false
90
+ app .Settings .Prefork = prefork
95
91
}
96
- if settings [ 0 ] .BodyLimit == 0 { // Default MaxRequestBodySize
97
- settings [ 0 ] .BodyLimit = 4 * 1024 * 1024
92
+ if app . Settings .BodyLimit == 0 { // Default MaxRequestBodySize
93
+ app . Settings .BodyLimit = 4 * 1024 * 1024
98
94
}
99
- if settings [ 0 ] .Immutable { // Replace unsafe conversion funcs
95
+ if app . Settings .Immutable { // Replace unsafe conversion funcs
100
96
getString = func (b []byte ) string { return string (b ) }
101
97
getBytes = func (s string ) []byte { return []byte (s ) }
102
98
}
103
- app .Settings = settings [0 ] // Set custom settings
99
+ }
100
+ // Deprecated
101
+ if app .Settings .Compression {
102
+ log .Println ("Warning: Settings.Compression is deprecated since v1.8.2, please use github.com/gofiber/compression instead." )
104
103
}
105
104
return app
106
105
}
@@ -201,14 +200,14 @@ func (app *App) All(path string, handlers ...func(*Ctx)) *App {
201
200
}
202
201
203
202
// WebSocket : https://fiber.wiki/application#websocket
204
- func (app * App ) WebSocket (path string , handle func (* Conn )) * App {
203
+ func (app * App ) WebSocket (path string , handle func (* Ctx )) * App {
205
204
app .registerWebSocket (http .MethodGet , path , handle )
206
205
return app
207
206
}
208
207
209
208
// Recover : https://fiber.wiki/application#recover
210
209
func (app * App ) Recover (handler func (* Ctx )) {
211
- log .Println ("Warning: Recover(handler ) is deprecated since v1.8.2, please use middleware.Recover(handler, error) instead." )
210
+ log .Println ("Warning: app. Recover() is deprecated since v1.8.2, please use github.com/gofiber/recover instead." )
212
211
app .recover = handler
213
212
}
214
213
@@ -362,9 +361,8 @@ func (app *App) newServer() *fasthttp.Server {
362
361
Name : app .Settings .ServerHeader ,
363
362
MaxRequestBodySize : app .Settings .BodyLimit ,
364
363
NoDefaultServerHeader : app .Settings .ServerHeader == "" ,
365
-
366
- Logger : & disableLogger {},
367
- LogAllErrors : false ,
364
+ Logger : & disableLogger {},
365
+ LogAllErrors : false ,
368
366
ErrorHandler : func (ctx * fasthttp.RequestCtx , err error ) {
369
367
if err .Error () == "body size exceeds the given limit" {
370
368
ctx .Response .SetStatusCode (413 )
0 commit comments