MCPcopy
hub / github.com/go-chi/chi / Context

Struct Context

context.go:45–79  ·  view source on GitHub ↗

Context is the default routing context set on the root node of a request context to track route patterns, URL parameters and an optional routing path.

Source from the content-addressed store, hash-verified

43// request context to track route patterns, URL parameters and
44// an optional routing path.
45type Context struct {
46 Routes Routes
47
48 // parentCtx is the parent of this one, for using Context as a
49 // context.Context directly. This is an optimization that saves
50 // 1 allocation.
51 parentCtx context.Context
52
53 // Routing path/method override used during the route search.
54 // See Mux#routeHTTP method.
55 RoutePath string
56 RouteMethod string
57
58 // URLParams are the stack of routeParams captured during the
59 // routing lifecycle across a stack of sub-routers.
60 URLParams RouteParams
61
62 // Route parameters matched for the current sub-router. It is
63 // intentionally unexported so it can't be tampered.
64 routeParams RouteParams
65
66 // The endpoint routing pattern that matched the request URI path
67 // or `RoutePath` of the current sub-router. This value will update
68 // during the lifecycle of a request passing through a stack of
69 // sub-routers.
70 routePattern string
71
72 // Routing pattern stack throughout the lifecycle of the request,
73 // across all connected routers. It is a record of all matching
74 // patterns across a stack of sub-routers.
75 RoutePatterns []string
76
77 methodsAllowed []methodTyp // allowed methods in case of a 405
78 methodNotAllowed bool
79}
80
81// Reset a routing context to its initial state.
82func (x *Context) Reset() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected