TypeCore
SqurlMux
The main multiplexer for routing HTTP requests and managing middleware in Squirrel Framework.
Type Definition
type SqurlMux struct {
// grouping together the routes
// the server mux
routes []route
// global middlewares
// also an application have more than one middleware
middleware []Middleware
}Methods
Listen()
Starts the server listening on the specified address.
func (s *SqurlMux) Listen(addr string)Use()
Adds global middleware to the request processing pipeline.
func (s *SqurlMux) Use(mw Middleware)Get()
Registers a GET route handler with optional route-specific middleware.
func (s *SqurlMux) Get(path string, handler HandlerFunc, mws ...Middleware)Post()
Registers a POST route handler with optional route-specific middleware.
func (s *SqurlMux) Post(path string, handler HandlerFunc, mws ...Middleware)Put()
Registers a PUT route handler with optional route-specific middleware.
func (s *SqurlMux) Put(path string, handler HandlerFunc, mws ...Middleware)Delete()
Registers a DELETE route handler with optional route-specific middleware.
func (s *SqurlMux) Delete(path string, handler HandlerFunc, mws ...Middleware)SqurlMux supports middleware at both global level (using
Use()) and route-specific level (as additional parameters to route methods). Route-specific middleware is executed after global middleware.