appendSubAppLists supports nested for sub apps
(appList map[string]*App, parent ...string)
| 139 | |
| 140 | // appendSubAppLists supports nested for sub apps |
| 141 | func (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 |
| 170 | func (app *App) processSubAppsRoutes() { |
no test coverage detected