mount.go — fiber Source File
Architecture documentation for mount.go, a go file in the fiber codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 34d36804_2637_7a71_6d1e_4c70cf8761e5["mount.go"] 5475551c_3f53_d25b_bcfb_7e8cde36a64b["sort"] 34d36804_2637_7a71_6d1e_4c70cf8761e5 --> 5475551c_3f53_d25b_bcfb_7e8cde36a64b style 34d36804_2637_7a71_6d1e_4c70cf8761e5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
// ⚡️ Fiber is an Express inspired web framework written in Go with ☕️
// 🤖 GitHub Repository: https://github.com/gofiber/fiber
// 📌 API Documentation: https://docs.gofiber.io
package fiber
import (
"sort"
"sync"
"sync/atomic"
"github.com/gofiber/utils/v2"
)
// Put fields related to mounting.
type mountFields struct {
// Mounted and main apps
appList map[string]*App
// Prefix of app if it was mounted
mountPath string
// Ordered keys of apps (sorted by key length for Render)
appListKeys []string
// check added routes of sub-apps
subAppsRoutesAdded sync.Once
// check mounted sub-apps
subAppsProcessed sync.Once
}
// Create empty mountFields instance
func newMountFields(app *App) *mountFields {
return &mountFields{
appList: map[string]*App{"": app},
appListKeys: make([]string, 0),
}
}
// Mount attaches another app instance as a sub-router along a routing path.
// It's very useful to split up a large API as many independent routers and
// compose them as a single service using Mount. The fiber's error handler and
// any of the fiber's sub apps are added to the application's error handlers
// to be invoked on errors that happen within the prefix route.
func (app *App) mount(prefix string, subApp *App) Router {
prefix = utils.TrimRight(prefix, '/')
if prefix == "" {
prefix = "/"
}
app.mutex.Lock()
// Support for configs of mounted-apps and sub-mounted-apps
for mountedPrefixes, subApp := range subApp.mountFields.appList {
path := getGroupPath(prefix, mountedPrefixes)
subApp.mountFields.mountPath = path
app.mountFields.appList[path] = subApp
}
app.mutex.Unlock()
// register mounted group
mountGroup := &Group{Prefix: prefix, app: subApp}
app.register([]string{methodUse}, prefix, mountGroup)
// ... (168 more lines)
Domain
Subdomains
Functions
Classes
Types
Dependencies
- sort
Source
Frequently Asked Questions
What does mount.go do?
mount.go is a source file in the fiber codebase, written in go. It belongs to the FiberCore domain, Context subdomain.
What functions are defined in mount.go?
mount.go defines 1 function(s): newMountFields.
What does mount.go depend on?
mount.go imports 1 module(s): sort.
Where is mount.go in the architecture?
mount.go is located at mount.go (domain: FiberCore, subdomain: Context).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free