Home / File/ register.go — fiber Source File

register.go — fiber Source File

Architecture documentation for register.go, a go file in the fiber codebase.

Entity Profile

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

// Register defines all router handle interface generate by RouteChain().
type Register interface {
	All(handler any, handlers ...any) Register
	Get(handler any, handlers ...any) Register
	Head(handler any, handlers ...any) Register
	Post(handler any, handlers ...any) Register
	Put(handler any, handlers ...any) Register
	Delete(handler any, handlers ...any) Register
	Connect(handler any, handlers ...any) Register
	Options(handler any, handlers ...any) Register
	Trace(handler any, handlers ...any) Register
	Patch(handler any, handlers ...any) Register

	Add(methods []string, handler any, handlers ...any) Register

	RouteChain(path string) Register
}

var _ Register = (*Registering)(nil)

// Registering provides route registration helpers for a specific path on the
// application instance.
type Registering struct {
	app   *App
	group *Group

	path string
}

// All registers a middleware route that will match requests
// with the provided path which is stored in register struct.
//
//	app.RouteChain("/").All(func(c fiber.Ctx) error {
//	     return c.Next()
//	})
//	app.RouteChain("/api").All(func(c fiber.Ctx) error {
//	     return c.Next()
//	})
//	app.RouteChain("/api").All(handler, func(c fiber.Ctx) error {
//	     return c.Next()
//	})
//
// This method will match all HTTP verbs: GET, POST, PUT, HEAD etc...
func (r *Registering) All(handler any, handlers ...any) Register {
	converted := collectHandlers("register", append([]any{handler}, handlers...)...)
	r.app.register([]string{methodUse}, r.path, r.group, converted...)
	return r
}

// Get registers a route for GET methods that requests a representation
// of the specified resource. Requests using GET should only retrieve data.
func (r *Registering) Get(handler any, handlers ...any) Register {
	return r.Add([]string{MethodGet}, handler, handlers...)
}
// ... (65 more lines)

Analyze Your Own Codebase

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

Try Supermodel Free