Home / File/ group.go — fiber Source File

group.go — fiber Source File

Architecture documentation for group.go, a go file in the fiber codebase. 1 imports, 0 dependents.

File go 1 imports 4 classes

Entity Profile

Dependency Diagram

graph LR
  262d0587_e5a9_8b30_160b_2df2206a7011["group.go"]
  adf3d4e8_4d86_86c1_e6cc_281d7b4104af["fmt"]
  262d0587_e5a9_8b30_160b_2df2206a7011 --> adf3d4e8_4d86_86c1_e6cc_281d7b4104af
  style 262d0587_e5a9_8b30_160b_2df2206a7011 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 (
	"fmt"
	"reflect"
)

// Group represents a collection of routes that share middleware and a common
// path prefix.
type Group struct {
	app         *App
	parentGroup *Group
	name        string

	Prefix          string
	anyRouteDefined bool
}

// Name Assign name to specific route or group itself.
//
// If this method is used before any route added to group, it'll set group name and OnGroupNameHook will be used.
// Otherwise, it'll set route name and OnName hook will be used.
func (grp *Group) Name(name string) Router {
	if grp.anyRouteDefined {
		grp.app.Name(name)

		return grp
	}

	grp.app.mutex.Lock()
	if grp.parentGroup != nil {
		grp.name = grp.parentGroup.name + name
	} else {
		grp.name = name
	}

	if err := grp.app.hooks.executeOnGroupNameHooks(*grp); err != nil {
		panic(err)
	}
	grp.app.mutex.Unlock()

	return grp
}

// Use registers a middleware route that will match requests
// with the provided prefix (which is optional and defaults to "/").
// Also, you can pass 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 Use. 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.
//
//		app.Use(func(c fiber.Ctx) error {
//		     return c.Next()
//		})
//		app.Use("/api", func(c fiber.Ctx) error {
// ... (170 more lines)

Types

Dependencies

  • fmt

Frequently Asked Questions

What does group.go do?
group.go is a source file in the fiber codebase, written in go.
What does group.go depend on?
group.go imports 1 module(s): fmt.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free