Skip to content

Commit

Permalink
#550 added in playground examples of splitters
Browse files Browse the repository at this point in the history
  • Loading branch information
zorba71 committed Feb 5, 2024
1 parent bf32a9c commit 3739ea3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
{
"my-queue-1" : {
"queue-static-split": {
"postfixFromStatic": [
"A",
"B",
"C",
"D"
]
},
"my-queue-[0-9]+" : {
"queue-header-[a-z]+": {
"postfixDelimiter": "+",
"postfixFromHeader": "{x-rp-deviceid}"
"postfixFromHeader": "x-rp-deviceid"
},
"my-queue-[a-zA-Z]+" : {
"queue-path-[a-z]+": {
"postfixDelimiter": "_",
"postfixFromUrl": ".*/path1/(.*)/path3/path4/.*"
"postfixFromUrl": ".*/path1/(.*)/.*"
},
"queue-header-and-path-[a-z]+": {
"postfixDelimiter": "_",
"postfixFromHeader": "x-rp-deviceid",
"postfixFromUrl": ".*/path1/(.*)/.*"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ public String executeSplit(String queue, HttpServerRequest request) {
}
}
if (configuration.getPostfixFromHeader() != null) {
stringBuilder.append(configuration.getPostfixDelimiter());
stringBuilder.append(request.headers().get(configuration.getPostfixFromHeader()));
String headerValue = request.headers().get(configuration.getPostfixFromHeader());
if (headerValue != null) {
stringBuilder.append(configuration.getPostfixDelimiter());
stringBuilder.append(headerValue);
}
}
}
return stringBuilder.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void testExecuteSplitWithHeaderButMissingInRequest() {
when(request.headers()).thenReturn(new HeadersMultiMap());

// Then
assertEquals("queue-1-null", executor.executeSplit("queue-1", request));
assertEquals("queue-1", executor.executeSplit("queue-1", request));
}

@Test
Expand Down

0 comments on commit 3739ea3

Please sign in to comment.