Skip to content

Commit

Permalink
use once
Browse files Browse the repository at this point in the history
  • Loading branch information
efectn committed Oct 20, 2022
1 parent dddea6b commit b84cd20
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ type App struct {
// TLS handler
tlsHandler *TLSHandler
// check added routes of sub-apps
subAppsRoutesAdded bool
subAppsRoutesAdded sync.Once
// Returns parent app if app was mounted
parentApp *App
// Prefix of app if it was mounted
Expand Down Expand Up @@ -1036,12 +1036,10 @@ func (app *App) startupProcess() *App {
defer app.mutex.Unlock()

// add routes of sub-apps
if !app.subAppsRoutesAdded {
app.subAppsRoutesAdded.Do(func() {
app.appendSubAppLists(app.appList)
app.addSubAppsRoutes(app.appList)

app.subAppsRoutesAdded = true
}
})

// build route tree stack
app.buildTree()
Expand Down

0 comments on commit b84cd20

Please sign in to comment.