Skip to content

Commit

Permalink
[TT-7186] Move x-api-version to a constant (TykTechnologies#4463)
Browse files Browse the repository at this point in the history
  • Loading branch information
furkansenharputlu authored Dec 14, 2022
1 parent 2b14ec5 commit 8fc870f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion apidef/api_definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ const (
URLLocation = "url"
ExpirationTimeFormat = "2006-01-02 15:04"

Self = "self"
Self = "self"
DefaultAPIVersionKey = "x-api-version"

AuthTokenType = "authToken"
JWTType = "jwt"
Expand Down
8 changes: 4 additions & 4 deletions gateway/api_definition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1023,11 +1023,11 @@ func TestGetVersionFromRequest(t *testing.T) {
spec.Proxy.ListenPath = "/"
spec.VersionData.NotVersioned = false
spec.VersionDefinition.Location = apidef.HeaderLocation
spec.VersionDefinition.Key = "X-API-Version"
spec.VersionDefinition.Key = apidef.DefaultAPIVersionKey
spec.VersionData.Versions["v1"] = versionInfo
})[0]

headers := map[string]string{"X-API-Version": "v1"}
headers := map[string]string{apidef.DefaultAPIVersionKey: "v1"}

_, _ = ts.Run(t, []test.TestCase{
{Path: "/foo", Code: http.StatusOK, Headers: headers, BodyMatch: `"X-Api-Version":"v1"`},
Expand Down Expand Up @@ -1107,11 +1107,11 @@ func BenchmarkGetVersionFromRequest(b *testing.B) {
spec.Proxy.ListenPath = "/"
spec.VersionData.NotVersioned = false
spec.VersionDefinition.Location = apidef.HeaderLocation
spec.VersionDefinition.Key = "X-API-Version"
spec.VersionDefinition.Key = apidef.DefaultAPIVersionKey
spec.VersionData.Versions["v1"] = versionInfo
})

headers := map[string]string{"X-API-Version": "v1"}
headers := map[string]string{apidef.DefaultAPIVersionKey: "v1"}

for i := 0; i < b.N; i++ {
ts.Run(b, []test.TestCase{
Expand Down

0 comments on commit 8fc870f

Please sign in to comment.