Home / Function/ New() — fiber Function Reference

New() — fiber Function Reference

Architecture documentation for the New() function in expvar.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  05fc4ca5_3613_f1f4_223f_82efd0f25105["New()"]
  6b3e42fe_8225_b307_8ede_972b4d23b95c["expvar.go"]
  05fc4ca5_3613_f1f4_223f_82efd0f25105 -->|defined in| 6b3e42fe_8225_b307_8ede_972b4d23b95c
  style 05fc4ca5_3613_f1f4_223f_82efd0f25105 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/expvar/expvar.go lines 11–34

func New(config ...Config) fiber.Handler {
	// Set default config
	cfg := configDefault(config...)

	// Return new handler
	return func(c fiber.Ctx) error {
		// Don't execute middleware if Next returns true
		if cfg.Next != nil && cfg.Next(c) {
			return c.Next()
		}

		path := c.Path()
		// We are only interested in /debug/vars routes
		if len(path) < 11 || !strings.HasPrefix(path, "/debug/vars") {
			return c.Next()
		}
		if path == "/debug/vars" {
			expvarhandler.ExpvarHandler(c.RequestCtx())
			return nil
		}

		return c.Redirect().To("/debug/vars")
	}
}

Domain

Subdomains

Frequently Asked Questions

What does New() do?
New() is a function in the fiber codebase, defined in middleware/expvar/expvar.go.
Where is New() defined?
New() is defined in middleware/expvar/expvar.go at line 11.

Analyze Your Own Codebase

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

Try Supermodel Free