MCPcopy Create free account
hub / github.com/kataras/iris / NewGroup

Function NewGroup

versioning/group.go:86–115  ·  view source on GitHub ↗

NewGroup returns a version Group based on the given "version" constraint. Group completes the Party interface. The returned Group wraps a cloned Party of the given "r" Party therefore, any changes to its parent won't affect this one (e.g. register global middlewares afterwards). A version is extrac

(r API, version string)

Source from the content-addressed store, hash-verified

84//
85// but not `4.2.1`, `2.1.1`
86func NewGroup(r API, version string) *Group {
87 version = strings.ReplaceAll(version, ",", " ")
88 version = strings.TrimSpace(version)
89
90 verRange, err := semver.ParseRange(version)
91 if err != nil {
92 r.Logger().Errorf("versioning: %s: %s", r.GetRelPath(), strings.ToLower(err.Error()))
93 return &Group{API: r}
94 }
95
96 // Clone this one.
97 r = r.Party("/")
98
99 // Note that this feature alters the RouteRegisterRule to RouteOverlap
100 // the RouteOverlap rule does not contain any performance downside
101 // but it's good to know that if you registered other mode, this wanna change it.
102 r.SetRegisterRule(router.RouteOverlap)
103
104 handler := makeHandler(verRange)
105 // This is required in order to not populate this middleware to the next group.
106 r.UseOnce(handler)
107 // This is required for versioned custom error handlers,
108 // of course if the parent registered one then this will do nothing.
109 r.UseError(handler)
110
111 return &Group{
112 API: r,
113 validate: verRange,
114 }
115}
116
117// Deprecated marks this group and all its versioned routes
118// as deprecated versions of that endpoint.

Callers 3

mainFunction · 0.92
TestVersionAliasesFunction · 0.92
TestNewGroupFunction · 0.92

Calls 9

ErrorfMethod · 0.80
makeHandlerFunction · 0.70
LoggerMethod · 0.65
GetRelPathMethod · 0.65
ErrorMethod · 0.65
PartyMethod · 0.65
SetRegisterRuleMethod · 0.65
UseOnceMethod · 0.65
UseErrorMethod · 0.65

Tested by 2

TestVersionAliasesFunction · 0.74
TestNewGroupFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…