@@ -29,8 +29,8 @@ const Version = "1.8.43"
29
29
// Map is a shortcut for map[string]interface{}
30
30
type Map map [string ]interface {}
31
31
32
- // Fiber denotes the Fiber application.
33
- type Fiber struct {
32
+ // App denotes the Fiber application.
33
+ type App struct {
34
34
server * fasthttp.Server // FastHTTP server
35
35
routes []* Route // Route stack
36
36
Settings * Settings // Fiber settings
@@ -67,15 +67,15 @@ type Settings struct {
67
67
// Group struct
68
68
type Group struct {
69
69
prefix string
70
- app * Fiber
70
+ app * App
71
71
}
72
72
73
73
// Global variables
74
74
var isPrefork , isChild bool
75
75
76
76
// New creates a new Fiber named instance.
77
77
// You can pass optional settings when creating a new instance.
78
- func New (settings ... * Settings ) * Fiber {
78
+ func New (settings ... * Settings ) * App {
79
79
// Parse arguments
80
80
for _ , v := range os .Args [1 :] {
81
81
if v == "-prefork" {
@@ -85,7 +85,7 @@ func New(settings ...*Settings) *Fiber {
85
85
}
86
86
}
87
87
// Create app
88
- app := new (Fiber )
88
+ app := new (App )
89
89
// Create settings
90
90
app .Settings = new (Settings )
91
91
// Set default settings
@@ -109,7 +109,7 @@ func New(settings ...*Settings) *Fiber {
109
109
}
110
110
111
111
// Group is used for Routes with common prefix to define a new sub-router with optional middleware.
112
- func (app * Fiber ) Group (prefix string , handlers ... func (* Ctx )) * Group {
112
+ func (app * App ) Group (prefix string , handlers ... func (* Ctx )) * Group {
113
113
if len (handlers ) > 0 {
114
114
app .registerMethod ("USE" , prefix , handlers ... )
115
115
}
@@ -139,15 +139,15 @@ type Static struct {
139
139
}
140
140
141
141
// Static registers a new route with path prefix to serve static files from the provided root directory.
142
- func (app * Fiber ) Static (prefix , root string , config ... Static ) * Fiber {
142
+ func (app * App ) Static (prefix , root string , config ... Static ) * App {
143
143
app .registerStatic (prefix , root , config ... )
144
144
return app
145
145
}
146
146
147
147
// Use registers a middleware route.
148
148
// Middleware matches requests beginning with the provided prefix.
149
149
// Providing a prefix is optional, it defaults to "/"
150
- func (app * Fiber ) Use (args ... interface {}) * Fiber {
150
+ func (app * App ) Use (args ... interface {}) * App {
151
151
var path = ""
152
152
var handlers []func (* Ctx )
153
153
for i := 0 ; i < len (args ); i ++ {
@@ -165,61 +165,61 @@ func (app *Fiber) Use(args ...interface{}) *Fiber {
165
165
}
166
166
167
167
// Connect : https://fiber.wiki/application#http-methods
168
- func (app * Fiber ) Connect (path string , handlers ... func (* Ctx )) * Fiber {
168
+ func (app * App ) Connect (path string , handlers ... func (* Ctx )) * App {
169
169
app .registerMethod (MethodConnect , path , handlers ... )
170
170
return app
171
171
}
172
172
173
173
// Put : https://fiber.wiki/application#http-methods
174
- func (app * Fiber ) Put (path string , handlers ... func (* Ctx )) * Fiber {
174
+ func (app * App ) Put (path string , handlers ... func (* Ctx )) * App {
175
175
app .registerMethod (MethodPut , path , handlers ... )
176
176
return app
177
177
}
178
178
179
179
// Post : https://fiber.wiki/application#http-methods
180
- func (app * Fiber ) Post (path string , handlers ... func (* Ctx )) * Fiber {
180
+ func (app * App ) Post (path string , handlers ... func (* Ctx )) * App {
181
181
app .registerMethod (MethodPost , path , handlers ... )
182
182
return app
183
183
}
184
184
185
185
// Delete : https://fiber.wiki/application#http-methods
186
- func (app * Fiber ) Delete (path string , handlers ... func (* Ctx )) * Fiber {
186
+ func (app * App ) Delete (path string , handlers ... func (* Ctx )) * App {
187
187
app .registerMethod (MethodDelete , path , handlers ... )
188
188
return app
189
189
}
190
190
191
191
// Head : https://fiber.wiki/application#http-methods
192
- func (app * Fiber ) Head (path string , handlers ... func (* Ctx )) * Fiber {
192
+ func (app * App ) Head (path string , handlers ... func (* Ctx )) * App {
193
193
app .registerMethod (MethodHead , path , handlers ... )
194
194
return app
195
195
}
196
196
197
197
// Patch : https://fiber.wiki/application#http-methods
198
- func (app * Fiber ) Patch (path string , handlers ... func (* Ctx )) * Fiber {
198
+ func (app * App ) Patch (path string , handlers ... func (* Ctx )) * App {
199
199
app .registerMethod (MethodPatch , path , handlers ... )
200
200
return app
201
201
}
202
202
203
203
// Options : https://fiber.wiki/application#http-methods
204
- func (app * Fiber ) Options (path string , handlers ... func (* Ctx )) * Fiber {
204
+ func (app * App ) Options (path string , handlers ... func (* Ctx )) * App {
205
205
app .registerMethod (MethodOptions , path , handlers ... )
206
206
return app
207
207
}
208
208
209
209
// Trace : https://fiber.wiki/application#http-methods
210
- func (app * Fiber ) Trace (path string , handlers ... func (* Ctx )) * Fiber {
210
+ func (app * App ) Trace (path string , handlers ... func (* Ctx )) * App {
211
211
app .registerMethod (MethodTrace , path , handlers ... )
212
212
return app
213
213
}
214
214
215
215
// Get : https://fiber.wiki/application#http-methods
216
- func (app * Fiber ) Get (path string , handlers ... func (* Ctx )) * Fiber {
216
+ func (app * App ) Get (path string , handlers ... func (* Ctx )) * App {
217
217
app .registerMethod (MethodGet , path , handlers ... )
218
218
return app
219
219
}
220
220
221
221
// All matches all HTTP methods and complete paths
222
- func (app * Fiber ) All (path string , handlers ... func (* Ctx )) * Fiber {
222
+ func (app * App ) All (path string , handlers ... func (* Ctx )) * App {
223
223
app .registerMethod ("ALL" , path , handlers ... )
224
224
return app
225
225
}
@@ -325,7 +325,7 @@ func (grp *Group) All(path string, handlers ...func(*Ctx)) *Group {
325
325
326
326
// Listen serves HTTP requests from the given addr or port.
327
327
// You can pass an optional *tls.Config to enable TLS.
328
- func (app * Fiber ) Listen (address interface {}, tlsconfig ... * tls.Config ) error {
328
+ func (app * App ) Listen (address interface {}, tlsconfig ... * tls.Config ) error {
329
329
addr , ok := address .(string )
330
330
if ! ok {
331
331
port , ok := address .(int )
@@ -370,7 +370,7 @@ func (app *Fiber) Listen(address interface{}, tlsconfig ...*tls.Config) error {
370
370
// Make sure the program doesn't exit and waits instead for Shutdown to return.
371
371
//
372
372
// Shutdown does not close keepalive connections so its recommended to set ReadTimeout to something else than 0.
373
- func (app * Fiber ) Shutdown () error {
373
+ func (app * App ) Shutdown () error {
374
374
if app .server == nil {
375
375
return fmt .Errorf ("Server is not running" )
376
376
}
@@ -379,7 +379,7 @@ func (app *Fiber) Shutdown() error {
379
379
380
380
// Test is used for internal debugging by passing a *http.Request.
381
381
// Timeout is optional and defaults to 200ms, -1 will disable it completely.
382
- func (app * Fiber ) Test (request * http.Request , msTimeout ... int ) (* http.Response , error ) {
382
+ func (app * App ) Test (request * http.Request , msTimeout ... int ) (* http.Response , error ) {
383
383
timeout := 200
384
384
if len (msTimeout ) > 0 {
385
385
timeout = msTimeout [0 ]
@@ -426,7 +426,7 @@ func (app *Fiber) Test(request *http.Request, msTimeout ...int) (*http.Response,
426
426
}
427
427
428
428
// Sharding: https://www.nginx.com/blog/socket-sharding-nginx-release-1-9-1/
429
- func (app * Fiber ) prefork (address string ) (ln net.Listener , err error ) {
429
+ func (app * App ) prefork (address string ) (ln net.Listener , err error ) {
430
430
// Master proc
431
431
if ! isChild {
432
432
addr , err := net .ResolveTCPAddr ("tcp" , address )
@@ -474,7 +474,7 @@ func (dl *disableLogger) Printf(format string, args ...interface{}) {
474
474
// fmt.Println(fmt.Sprintf(format, args...))
475
475
}
476
476
477
- func (app * Fiber ) newServer () * fasthttp.Server {
477
+ func (app * App ) newServer () * fasthttp.Server {
478
478
return & fasthttp.Server {
479
479
Handler : app .handler ,
480
480
Name : app .Settings .ServerHeader ,
0 commit comments