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)
| 58 | // set the version constraint from a given URL Query Parameter. |
| 59 | // The X-Api-Version is still valid. |
| 60 | func 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". |
nothing calls this directly
no test coverage detected
searching dependent graphs…