Documentation
¶
Overview ¶
Package router provides HTTP request routing with metrics integration. It wraps the julienschmidt/httprouter library and adds automatic endpoint metrics collection.
Index ¶
- type Params
- type Router
- func (r *Router) DELETE(path string, handler http.Handler) *Router
- func (r *Router) GET(path string, handler http.Handler) *Router
- func (r *Router) Handler(method string, path string, handler http.Handler) *Router
- func (r *Router) InternalRouter() *httprouter.Router
- func (r *Router) POST(path string, handler http.Handler) *Router
- func (r *Router) PUT(path string, handler http.Handler) *Router
- func (r *Router) ServeHTTP(writer http.ResponseWriter, request *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Params ¶
type Params = httprouter.Params
Params is an alias for httprouter.Params, representing URL path parameters.
func ParamsFromContext ¶
ParamsFromContext extracts URL path parameters from a context. It returns empty params if none are present in the context.
func ParamsFromRequest ¶
ParamsFromRequest extracts URL path parameters from an http.Request. It retrieves the parameters from the request context.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router wraps httprouter.Router with automatic metrics collection for each endpoint. It supports method-based routing (GET, POST, PUT, DELETE) and fluent API for route configuration.
func (*Router) DELETE ¶
DELETE registers an HTTP DELETE handler for the specified path. Returns the Router for fluent chaining.
func (*Router) GET ¶
GET registers an HTTP GET handler for the specified path. Returns the Router for fluent chaining.
func (*Router) Handler ¶
Handler registers a handler for the specified HTTP method and path. It automatically wraps the handler with metrics collection. Returns the Router for fluent chaining.
func (*Router) InternalRouter ¶
func (r *Router) InternalRouter() *httprouter.Router
InternalRouter returns the underlying httprouter instance for advanced configuration.
func (*Router) POST ¶
POST registers an HTTP POST handler for the specified path. Returns the Router for fluent chaining.