(ctx *context.Context, validate semver.Range)
| 101 | } |
| 102 | |
| 103 | func matchVersionRange(ctx *context.Context, validate semver.Range) bool { |
| 104 | gotVersion := GetVersion(ctx) |
| 105 | |
| 106 | alias, aliasFound := GetVersionAlias(ctx, gotVersion) |
| 107 | if aliasFound { |
| 108 | SetVersion(ctx, alias) // set the version so next routes have it already. |
| 109 | gotVersion = alias |
| 110 | } |
| 111 | |
| 112 | if gotVersion == "" { |
| 113 | return false |
| 114 | } |
| 115 | |
| 116 | v, err := semver.Make(gotVersion) |
| 117 | if err != nil { |
| 118 | return false |
| 119 | } |
| 120 | |
| 121 | if !validate(v) { |
| 122 | return false |
| 123 | } |
| 124 | |
| 125 | versionString := v.String() |
| 126 | |
| 127 | if !aliasFound { // don't lose any time to set if already set. |
| 128 | SetVersion(ctx, versionString) |
| 129 | } |
| 130 | |
| 131 | ctx.Header(APIVersionResponseHeader, versionString) |
| 132 | return true |
| 133 | } |
| 134 | |
| 135 | // GetVersion returns the current request version. |
| 136 | // |
no test coverage detected
searching dependent graphs…