route

package
v0.5.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2025 License: GPL-3.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilRouter     = errors.New("router cannot be nil")
	ErrNilController = errors.New("route controller cannot be nil")
	ErrNilService    = errors.New("route service cannot be nil")
)

Functions

func ChainHandlerFunctions added in v0.5.10

func ChainHandlerFunctions(handlerFunctions ...http.HandlerFunc) http.HandlerFunc

ChainHandlerFunctions chains the handlers functions

func ChainHandlers added in v0.5.10

func ChainHandlers(handlers ...http.Handler) http.Handler

ChainHandlers chains the handlers

Types

type Controller added in v0.2.1

type Controller struct {
	RouterWrapper
}

Controller is the struct for the route controller

type ControllerWrapper added in v0.2.2

type ControllerWrapper interface {
	RegisterRoutes()
	RegisterGroups()
}

ControllerWrapper is the interface for the route controller

type Logger added in v0.4.0

type Logger struct {
	// contains filtered or unexported fields
}

Logger is the logger for router

func NewLogger added in v0.4.0

func NewLogger(header string, modeLogger gologgermode.Logger) (*Logger, error)

NewLogger is the logger for the router

func (*Logger) RegisterRoute added in v0.4.0

func (l *Logger) RegisterRoute(routerPath string, routePath string)

RegisterRoute registers a route

func (*Logger) RegisterRouteGroup added in v0.4.0

func (l *Logger) RegisterRouteGroup(routerPath string, routerGroupPath string)

RegisterRouteGroup registers a route group

type Router added in v0.2.2

type Router struct {
	// contains filtered or unexported fields
}

Router is the route group struct

func NewBaseRouter added in v0.4.2

func NewBaseRouter(
	mode *goflagsmode.Flag,
	logger *Logger,
	handlers ...http.Handler,
) *Router

NewBaseRouter creates a new base router

func NewGroup

func NewGroup(
	baseRouter *Router,
	path string,
	handlers ...http.Handler,
) (*Router, error)

NewGroup creates a new router group

func NewRouter added in v0.2.2

func NewRouter(
	path string,
	mode *goflagsmode.Flag,
	logger *Logger,
	handlers ...http.Handler,
) *Router

NewRouter creates a new router

func (*Router) HandleFunc added in v0.2.2

func (r *Router) HandleFunc(path string, handlers ...http.HandlerFunc)

HandleFunc registers a new route with a path and the handlers functions It's not needed to call the next handler function in each handler

func (*Router) Handler added in v0.2.3

func (r *Router) Handler() http.Handler

Handler returns the first handler

func (*Router) Mux added in v0.5.10

func (r *Router) Mux() *http.ServeMux

Mux returns the multiplexer

func (*Router) NewGroup added in v0.4.2

func (r *Router) NewGroup(path string) *Router

NewGroup creates a new router group with a path

func (*Router) RegisterGroup added in v0.4.2

func (r *Router) RegisterGroup(path string, router *Router)

RegisterGroup registers a new router group with a path and a router

func (*Router) RegisterHandler added in v0.2.2

func (r *Router) RegisterHandler(path string, handler http.Handler)

RegisterHandler registers a new route group with a path and a handler function

func (*Router) RegisterRoute added in v0.2.2

func (r *Router) RegisterRoute(path string, handlers ...http.HandlerFunc)

RegisterRoute registers a new route with a path and the handlers functions It's not needed to call the next handler function in each handler

type RouterWrapper added in v0.2.2

type RouterWrapper interface {
	Handler() http.Handler
	Mux() *http.ServeMux
	HandleFunc(path string, handlers ...http.HandlerFunc)
	RegisterRoute(path string, handlers ...http.HandlerFunc)
	RegisterHandler(path string, handler http.Handler)
	NewGroup(path string) *Router
	RegisterGroup(path string, router *Router)
}

RouterWrapper is the interface for the routes

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL