Skip to content

Commit 10a46b1

Browse files
authored
Merge pull request #387 from SentryMan/helidon-path-patterns
Support Helidon Path Variable Patterns
2 parents b587709 + be87edd commit 10a46b1

File tree

4 files changed

+12
-53
lines changed

4 files changed

+12
-53
lines changed

http-generator-core/src/main/java/io/avaje/http/generator/core/PathSegments.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public static class Segment {
164164
* Create a normal segment.
165165
*/
166166
Segment(String name) {
167-
this.name = name;
167+
this.name = name.startsWith("+") ? name.substring(1) : name.split(":")[0];
168168
this.sanitizedName = Util.sanitizeName(name);
169169
this.literalSection = null;
170170
this.matrixKeys = null;

http-generator-helidon/src/main/java/io/avaje/http/generator/helidon/nima/ControllerMethodWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void writeRule() {
9292
} else if (isFilter) {
9393
writer.append(" routing.addFilter(this::_%s);", method.simpleName()).eol();
9494
} else {
95-
writer.append(" routing.%s(\"%s\", this::_%s);", webMethod.name().toLowerCase(), method.fullPath(), method.simpleName()).eol();
95+
writer.append(" routing.%s(\"%s\", this::_%s);", webMethod.name().toLowerCase(), method.fullPath().replace("\\", "\\\\"), method.simpleName()).eol();
9696
}
9797
}
9898

tests/test-nima-jsonb/.classpath

Lines changed: 0 additions & 51 deletions
This file was deleted.

tests/test-nima-jsonb/src/main/java/org/example/TestController.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,14 @@ String formBean(MyForm form) {
145145
String maybeNoContent(Boolean empty) {
146146
return Boolean.TRUE.equals(empty) ? null : "Hi";
147147
}
148+
149+
@Get("/peppermint/{patty:\\d+}")
150+
String pattern(String patty) {
151+
return patty.toString();
152+
}
153+
154+
@Get("/minus/{+plus}")
155+
String patternPlus(String plus) {
156+
return plus.toString();
157+
}
148158
}

0 commit comments

Comments
 (0)