Documentation
¶
Index ¶
Constants ¶
const ( ErrInvalidRequestBody = "invalid request body type, expected: %v" ErrNilSubmodule = "%s: submodule at index %d is nil" )
Variables ¶
var ( ErrCookieNotFound = errors.New("cookie not found") ErrNilRequestBody = errors.New("request body cannot be nil") ErrInDevelopment = errors.New("in development") ErrNilModule = errors.New("module cannot be nil") )
var (
ErrCodeCookieNotFound *string
)
Functions ¶
func GetClientIP ¶ added in v0.5.8
GetClientIP returns the client's IP address from the request
It checks the X-Forwarded-For header first (in case of proxies or load balancers), and falls back to the RemoteAddr if the header is not present.
Parameters:
- r: The HTTP request
Returns:
- string: The client's IP address
func NewMiddlewares ¶ added in v0.7.8
func NewMiddlewares(middlewares ...func(next http.Handler) http.Handler) []func(next http.Handler) http.Handler
NewMiddlewares is a function that creates a new middlewares slice
Usage: NewMiddlewares(middleware1, middleware2, ...)
Parameters:
- middlewares: variadic list of middleware functions
Returns:
- []func(next http.Handler) http.Handler: Slice of middleware functions
Types ¶
type Module ¶ added in v0.6.24
type Module struct {
Pattern string
Service interface{}
Controller interface{}
BeforeLoadFn func(m *Module)
RegisterRoutesFn func(m *Module)
AfterLoadFn func(m *Module)
Middlewares []func(next http.Handler) http.Handler
Submodules []*Module
gonethttproute.RouterWrapper
}
Module is the struct for the route module
func NewSubmodules ¶ added in v0.6.24
NewSubmodules is a function that creates a new submodules slice
Usage: NewSubmodules(submodule1, submodule2, ...)
Parameters:
- submodules: variadic list of submodule pointers
Returns:
- []*Module: Slice of submodule pointers
func (*Module) Create ¶ added in v0.6.24
func (m *Module) Create( baseRouter gonethttproute.RouterWrapper, ) error
Create is a function that creates the router for the controller and its submodules, and loads the module
Parameters:
- baseRouter: The base router to create the module's router group
Returns:
- error: The error if any
func (*Module) GetRouter ¶ added in v0.6.24
func (m *Module) GetRouter() gonethttproute.RouterWrapper
GetRouter returns the router
Returns:
- gonethttproute.RouterWrapper: The router