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

Function FromQuery

versioning/version.go:60–73  ·  view source on GitHub ↗

FromQuery is a simple helper which tries to set the version constraint from a given URL Query Parameter. The X-Api-Version is still valid.

(urlQueryParameterName string, defaultVersion string)

Source from the content-addressed store, hash-verified

58// set the version constraint from a given URL Query Parameter.
59// The X-Api-Version is still valid.
60func FromQuery(urlQueryParameterName string, defaultVersion string) context.Handler {
61 return func(ctx *context.Context) {
62 version := ctx.URLParam(urlQueryParameterName)
63 if version == "" {
64 version = defaultVersion
65 }
66
67 if version != "" {
68 SetVersion(ctx, version)
69 }
70
71 ctx.Next()
72 }
73}
74
75// If reports whether the "got" matches the "expected" one.
76// the "expected" can be a constraint like ">=1.0.0 <2.0.0".

Callers

nothing calls this directly

Calls 3

SetVersionFunction · 0.85
URLParamMethod · 0.80
NextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…