-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get a test for routing based upon regexes to pass for changing some c…
…ontent around. Many other tests fail, so this is still a WIP Signed-off-by: Greg Schohn <greg.schohn@gmail.com>
- Loading branch information
1 parent
12c0cfa
commit e68a155
Showing
5 changed files
with
49 additions
and
39 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
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
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
12 changes: 5 additions & 7 deletions
12
...jsonMessageTransformers/jsonJinjavaTransformer/src/main/resources/jinjava/common/route.j2
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 |
---|---|---|
@@ -1,22 +1,20 @@ | ||
{% import "common/featureEnabled.j2" as flags %} | ||
within import {{ __macros__ | pprint }} | ||
{% macro route(input, feature_flags, default_action, routes) %} | ||
{% macro route(input, field_to_match, feature_flags, default_action, routes) %} | ||
{%- set ns = namespace(result=none, matched=false) -%} | ||
{%- for feature_name, pattern_fn, action_fn in routes if not ns.matched -%} | ||
{%- for feature_name, pattern, action_fn in routes if not ns.matched -%} | ||
{%- if not ns.matched -%} {# we haven't found a match yet, otherwise skip the rest #} | ||
{%- set match = invoke_macro(pattern_fn, input) -%} | ||
{%- set match = field_to_match | regex_capture(pattern) -%} | ||
{%- if match is not none -%} | ||
{%- set ns.matched = true -%} | ||
{%- if flags.is_enabled(feature_flags, feature_name) -%} | ||
{%- set ns.result = invoke_macro(action_fn, match) -%} | ||
{%- set ns.result = invoke_macro(action_fn, match, input) -%} | ||
{%- endif -%} | ||
{%- endif -%} | ||
{%- endif -%} | ||
{%- endfor -%} | ||
{%- if ns.result is none -%} | ||
default answer: | ||
{{- invoke_macro(default_action, input) -}} | ||
{%- else -%} | ||
result: {{- ns.result -}} | ||
{{- ns.result -}} | ||
{%- endif -%} | ||
{% endmacro %} |
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