MCPcopy
hub / github.com/gofiber/fiber / appendSubAppLists

Method appendSubAppLists

mount.go:141–167  ·  view source on GitHub ↗

appendSubAppLists supports nested for sub apps

(appList map[string]*App, parent ...string)

Source from the content-addressed store, hash-verified

139
140// appendSubAppLists supports nested for sub apps
141func (app *App) appendSubAppLists(appList map[string]*App, parent ...string) {
142 // Optimize: Cache parent prefix
143 parentPrefix := ""
144 if len(parent) > 0 {
145 parentPrefix = parent[0]
146 }
147
148 for prefix, subApp := range appList {
149 // skip real app
150 if prefix == "" {
151 continue
152 }
153
154 if parentPrefix != "" {
155 prefix = getGroupPath(parentPrefix, prefix)
156 }
157
158 if _, ok := app.mountFields.appList[prefix]; !ok {
159 app.mountFields.appList[prefix] = subApp
160 }
161
162 // The first element of appList is always the app itself. If there are no other sub apps, we should skip appending nested apps.
163 if len(subApp.mountFields.appList) > 1 {
164 app.appendSubAppLists(subApp.mountFields.appList, prefix)
165 }
166 }
167}
168
169// processSubAppsRoutes adds routes of sub-apps recursively when the server is started
170func (app *App) processSubAppsRoutes() {

Callers 1

mountStartupProcessMethod · 0.95

Calls 1

getGroupPathFunction · 0.85

Tested by

no test coverage detected