diff --git a/filters/helpers.go b/filters/helpers.go new file mode 100644 index 0000000000..ff479e3ee4 --- /dev/null +++ b/filters/helpers.go @@ -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}, + } +} diff --git a/predicates/helpers.go b/predicates/helpers.go new file mode 100644 index 0000000000..2e0e8e81c0 --- /dev/null +++ b/predicates/helpers.go @@ -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}, + } +}