Skip to content

Commit

Permalink
fix(default) allow strip_path to be set to false
Browse files Browse the repository at this point in the history
Breaking change:

This is a limitation of how we fill in default values for the missing
values. It is not possible in Go to determine if a value is nil vs a
zero vaule (false for boolean).

Fixes #18
From #19
  • Loading branch information
hbagdi authored Jun 8, 2019
1 parent fe75a3b commit 29c2e4a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion utils/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var (
routeDefaults = kong.Route{
PreserveHost: kong.Bool(false),
RegexPriority: kong.Int(0),
StripPath: kong.Bool(true),
StripPath: kong.Bool(false),
Protocols: kong.StringSlice("http", "https"),
}
targetDefaults = kong.Target{
Expand Down
28 changes: 26 additions & 2 deletions utils/defaulter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func TestRouteSetTest(t *testing.T) {
want: &kong.Route{
PreserveHost: kong.Bool(true),
RegexPriority: kong.Int(0),
StripPath: kong.Bool(true),
StripPath: kong.Bool(false),
Protocols: kong.StringSlice("http", "https"),
},
},
Expand All @@ -156,7 +156,7 @@ func TestRouteSetTest(t *testing.T) {
want: &kong.Route{
PreserveHost: kong.Bool(false),
RegexPriority: kong.Int(0),
StripPath: kong.Bool(true),
StripPath: kong.Bool(false),
Protocols: kong.StringSlice("http", "tls"),
},
},
Expand All @@ -172,6 +172,30 @@ func TestRouteSetTest(t *testing.T) {
Name: kong.String("foo"),
Hosts: kong.StringSlice("1.example.com", "2.example.com"),
Methods: kong.StringSlice("GET", "POST"),
PreserveHost: kong.Bool(false),
RegexPriority: kong.Int(0),
StripPath: kong.Bool(false),
Protocols: kong.StringSlice("http", "https"),
},
},
{
desc: "strip-path can be set to false",
arg: &kong.Route{
StripPath: kong.Bool(false),
},
want: &kong.Route{
PreserveHost: kong.Bool(false),
RegexPriority: kong.Int(0),
StripPath: kong.Bool(false),
Protocols: kong.StringSlice("http", "https"),
},
},
{
desc: "strip-path can be set to true",
arg: &kong.Route{
StripPath: kong.Bool(true),
},
want: &kong.Route{
PreserveHost: kong.Bool(false),
RegexPriority: kong.Int(0),
StripPath: kong.Bool(true),
Expand Down

0 comments on commit 29c2e4a

Please sign in to comment.