Documentation
¶
Index ¶
- Constants
- func AddRoute(router *dynamicRouter) ...
- func GetHandler(router *dynamicRouter) http.Handler
- func GorillaMuxRouteMatcher(route Route) func(request *http.Request) RouteMatch
- func MatchRoute(routes *sync.Map, request *http.Request) (Route, RouteMatch)
- func NewDynamicRouter(routeMatcher RouteMatcherFunc, loggerFactory log.Factory) *dynamicRouter
- func RemoveRoute(router *dynamicRouter) func(routeId string)
- type Route
- type RouteContext
- type RouteMatch
- type RouteMatcherFunc
Constants ¶
const ContextRouteKey = "ContextRouteKey"
ContextRouteKey is a key for storing route information into the request context
Variables ¶
This section is empty.
Functions ¶
func AddRoute ¶
func AddRoute(router *dynamicRouter) func(path, pathPrefix string, methods []string, handler http.Handler) (string, error)
AddRoute adds a new route
func GetHandler ¶
GetHandler returns the router http.Handler
func GorillaMuxRouteMatcher ¶
func GorillaMuxRouteMatcher(route Route) func(request *http.Request) RouteMatch
GorillaMuxRouteMatcher is used for route matching
func MatchRoute ¶
MatchRoute checks all the route if they match the incoming request
func NewDynamicRouter ¶
func NewDynamicRouter(routeMatcher RouteMatcherFunc, loggerFactory log.Factory) *dynamicRouter
NewDynamicRouter creates a new dynamic router Its dynamic because it can add/remove routes at runtime this router does not do any route matching, it relies on third parties for that
func RemoveRoute ¶
func RemoveRoute(router *dynamicRouter) func(routeId string)
RemoveRoute removes a route
Types ¶
type Route ¶
type Route struct { UID string Path string PathPrefix string Methods []string Timeout time.Duration // contains filtered or unexported fields }
Route stores the information about a certain route
type RouteContext ¶
type RouteContext struct { Path string PathPrefix string Timeout time.Duration Vars map[string]string }
RouteContext is the object that gets stored into the request context
func GetRouteContextFromRequestContext ¶ added in v1.1.1
func GetRouteContextFromRequestContext(ctx context.Context) (RouteContext, bool)
type RouteMatch ¶
RouteMatch is the result of a route matching
type RouteMatcherFunc ¶
type RouteMatcherFunc func(route Route) func(request *http.Request) RouteMatch
RouteMatcherFunc type signature that any route matcher have to implement