Skip to content

Commit

Permalink
🐛fix: rename handlerCount to handlersCount (#1674)
Browse files Browse the repository at this point in the history
  • Loading branch information
vecpeng committed Dec 29, 2021
1 parent fbee8fb commit ef3a689
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions app.go
Expand Up @@ -98,7 +98,7 @@ type App struct {
// Amount of registered routes
routesCount uint32
// Amount of registered handlers
handlerCount uint32
handlersCount uint32
// Ctx pool
pool sync.Pool
// Fasthttp server
Expand Down Expand Up @@ -540,7 +540,7 @@ func (app *App) Mount(prefix string, fiber *App) Router {
app.errorHandlers[prefix+mountedPrefixes] = errHandler
}

atomic.AddUint32(&app.handlerCount, fiber.handlerCount)
atomic.AddUint32(&app.handlersCount, fiber.handlersCount)

return app
}
Expand Down Expand Up @@ -800,7 +800,7 @@ func (app *App) Stack() [][]*Route {

// HandlersCount returns the amount of registered handlers.
func (app *App) HandlersCount() uint32 {
return app.handlerCount
return app.handlersCount
}

// Shutdown gracefully shuts down the server without interrupting any active connections.
Expand Down Expand Up @@ -1104,7 +1104,7 @@ func (app *App) startupMessage(addr string, tls bool, pids string) {
" │ Prefork .%s PID ....%s │\n"+
" └───────────────────────────────────────────────────┘"+
cReset,
value(strconv.Itoa(int(app.handlerCount)), 14), value(procs, 12),
value(strconv.Itoa(int(app.handlersCount)), 14), value(procs, 12),
value(isPrefork, 14), value(strconv.Itoa(os.Getpid()), 14),
)

Expand Down
4 changes: 2 additions & 2 deletions app_test.go
Expand Up @@ -300,7 +300,7 @@ func Test_App_Mount(t *testing.T) {
resp, err := app.Test(httptest.NewRequest(MethodGet, "/john/doe", nil))
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
utils.AssertEqual(t, uint32(2), app.handlerCount)
utils.AssertEqual(t, uint32(2), app.handlersCount)
}

func Test_App_Use_Params(t *testing.T) {
Expand Down Expand Up @@ -931,7 +931,7 @@ func Test_App_Group_Mount(t *testing.T) {
resp, err := app.Test(httptest.NewRequest(MethodGet, "/v1/john/doe", nil))
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
utils.AssertEqual(t, uint32(2), app.handlerCount)
utils.AssertEqual(t, uint32(2), app.handlersCount)
}

func Test_App_Group(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion group.go
Expand Up @@ -41,7 +41,7 @@ func (grp *Group) Mount(prefix string, fiber *App) Router {
grp.app.errorHandlers[groupPath+mountedPrefixes] = errHandler
}

atomic.AddUint32(&grp.app.handlerCount, fiber.handlerCount)
atomic.AddUint32(&grp.app.handlersCount, fiber.handlersCount)

return grp
}
Expand Down
4 changes: 2 additions & 2 deletions router.go
Expand Up @@ -266,7 +266,7 @@ func (app *App) register(method, pathRaw string, handlers ...Handler) Router {
Handlers: handlers,
}
// Increment global handler count
atomic.AddUint32(&app.handlerCount, uint32(len(handlers)))
atomic.AddUint32(&app.handlersCount, uint32(len(handlers)))

// Middleware route matches all HTTP methods
if isUse {
Expand Down Expand Up @@ -403,7 +403,7 @@ func (app *App) registerStatic(prefix, root string, config ...Static) Router {
Handlers: []Handler{handler},
}
// Increment global handler count
atomic.AddUint32(&app.handlerCount, 1)
atomic.AddUint32(&app.handlersCount, 1)
// Add route to stack
app.addRoute(MethodGet, &route)
// Add HEAD route
Expand Down

0 comments on commit ef3a689

Please sign in to comment.