Skip to content

Commit

Permalink
Add runtime hints for CSS resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Kehrlann committed Sep 10, 2024
1 parent 2ecaa64 commit 23a735a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.aot.hint.TypeReference;
import org.springframework.core.io.ClassPathResource;
import org.springframework.security.web.access.expression.WebSecurityExpressionRoot;

/**
Expand All @@ -40,6 +41,12 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
TypeReference
.of("org.springframework.security.web.csrf.CsrfTokenRequestAttributeHandler$SupplierCsrfToken"),
MemberCategory.INVOKE_DECLARED_METHODS);

ClassPathResource css = new ClassPathResource("org/springframework/security/default-ui.css");
if (css.exists()) {
hints.resources().registerResource(css);
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,10 @@ void supplierCsrfTokenHasHints() {
.withMemberCategories(MemberCategory.INVOKE_DECLARED_METHODS)).accepts(this.hints);
}

@Test
void cssHasHints() {
assertThat(RuntimeHintsPredicates.resource().forResource("org/springframework/security/default-ui.css"))
.accepts(this.hints);
}

}

0 comments on commit 23a735a

Please sign in to comment.