-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added helpers for some predicates and filters
Signed-off-by: Peter Klijn <[email protected]>
- Loading branch information
1 parent
3507fc9
commit 61d97d8
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package filters | ||
|
||
import ( | ||
"github.com/zalando/skipper/eskip" | ||
"github.com/zalando/skipper/filters/builtin" | ||
"github.com/zalando/skipper/filters/cookie" | ||
"strconv" | ||
) | ||
|
||
func Status(statusCode int) *eskip.Filter { | ||
return &eskip.Filter{ | ||
Name: builtin.StatusName, | ||
Args: []interface{}{statusCode}, | ||
} | ||
} | ||
|
||
func InlineContent(text string) *eskip.Filter { | ||
return &eskip.Filter{ | ||
Name: builtin.InlineContentName, | ||
Args: []interface{}{text}, | ||
} | ||
} | ||
|
||
func InlineContentWithMime(text, mime string) *eskip.Filter { | ||
return &eskip.Filter{ | ||
Name: builtin.InlineContentName, | ||
Args: []interface{}{text, mime}, | ||
} | ||
} | ||
|
||
func PreserveHost(preserve bool) *eskip.Filter { | ||
return &eskip.Filter{ | ||
Name: builtin.PreserveHostName, | ||
Args: []interface{}{strconv.FormatBool(preserve)}, | ||
} | ||
} | ||
|
||
func ResponseCookie(name, value string) *eskip.Filter { | ||
return &eskip.Filter{ | ||
Name: cookie.ResponseCookieFilterName, | ||
Args: []interface{}{name, value}, | ||
} | ||
} | ||
|
||
func ResponseCookieWithSettings(name, value string, ttl float64, changeOnly bool) *eskip.Filter { | ||
return &eskip.Filter{ | ||
Name: cookie.ResponseCookieFilterName, | ||
Args: []interface{}{name, value, ttl, changeOnly}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package predicates | ||
|
||
import ( | ||
"github.com/zalando/skipper/eskip" | ||
"github.com/zalando/skipper/predicates/traffic" | ||
"github.com/zalando/skipper/routing" | ||
) | ||
|
||
func Path(path string) *eskip.Predicate { | ||
return &eskip.Predicate{ | ||
Name: routing.PathName, | ||
Args: []interface{}{path}, | ||
} | ||
} | ||
|
||
func Traffic(chance float64) *eskip.Predicate { | ||
return &eskip.Predicate{ | ||
Name: traffic.PredicateName, | ||
Args: []interface{}{chance}, | ||
} | ||
} | ||
|
||
func TrafficSticky(chance float64, trafficGroupCookie, trafficGroup string) *eskip.Predicate { | ||
return &eskip.Predicate{ | ||
Name: traffic.PredicateName, | ||
Args: []interface{}{chance, trafficGroupCookie, trafficGroup}, | ||
} | ||
} |