Skip to content

Commit

Permalink
update role generation
Browse files Browse the repository at this point in the history
  • Loading branch information
SentryMan committed Dec 6, 2024
1 parent 0411281 commit 87fb971
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,33 +47,32 @@ void writeRouting() {
final String fullPath = segments.fullPath();

if (method.isErrorMethod()) {
writer.append(" routing.error(%s.class, this::_%s)", method.exceptionShortName(), method.simpleName());
writer.append(" routing.error(%s.class, this::_%s", method.exceptionShortName(), method.simpleName());
} else if (isFilter) {
writer.append(" routing.filter(this::_%s)", method.simpleName());
writer.append(" routing.filter(this::_%s", method.simpleName());
} else {
writer.append(" routing.%s(\"%s\", ", webMethod.name().toLowerCase(), fullPath);
var hxRequest = method.hxRequest();
if (hxRequest != null) {
writeHxHandler(hxRequest);
} else {
writer.append("this::_%s)", method.simpleName());
writer.append("this::_%s", method.simpleName());
}
}
writeRoles();
writer.append(";").eol();
writer.append(");").eol();
}

private void writeRoles() {
List<String> roles = method.roles();
if (!roles.isEmpty()) {
writer.append(".withRoles(");
if (!roles.isEmpty() && !isFilter) {
writer.append(", ");
for (int i = 0; i < roles.size(); i++) {
if (i > 0) {
writer.append(", ");
}
writer.append(Util.shortName(roles.get(i), true));
}
writer.append(")");
}
}

Expand All @@ -92,7 +91,7 @@ private void writeHxHandler(HxRequestPrism hxRequest) {
} else if (hasValue(hxRequest.value())) {
writer.append(".triggerName(\"%s\")", hxRequest.value());
}
writer.append(".build())");
writer.append(".build()");
}

private static boolean hasValue(String value) {
Expand Down
2 changes: 1 addition & 1 deletion tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<junit.version>5.11.3</junit.version>
<assertj.version>3.26.3</assertj.version>
<jackson.version>2.18.2</jackson.version>
<jex.version>3.0-RC8</jex.version>
<jex.version>3.0-RC10</jex.version>
<avaje-inject.version>11.0</avaje-inject.version>
<nima.version>4.1.4</nima.version>
<javalin.version>6.3.0</javalin.version>
Expand Down

0 comments on commit 87fb971

Please sign in to comment.