Deprecate pathExtension routing predicates

Closes gh-34103
This commit is contained in:
rstoyanchev
2024-12-18 15:43:28 +00:00
parent 62d9600cdd
commit 41a9db376d
16 changed files with 108 additions and 17 deletions

View File

@@ -803,8 +803,7 @@ Java::
[source,java,indent=0,subs="verbatim,quotes"]
----
ClassPathResource index = new ClassPathResource("static/index.html");
List<String> extensions = List.of("js", "css", "ico", "png", "jpg", "gif");
RequestPredicate spaPredicate = path("/api/**").or(path("/error")).or(pathExtension(extensions::contains)).negate();
RequestPredicate spaPredicate = path("/api/**").or(path("/error")).negate();
RouterFunction<ServerResponse> redirectToIndex = route()
.resource(spaPredicate, index)
.build();
@@ -816,9 +815,7 @@ Kotlin::
----
val redirectToIndex = router {
val index = ClassPathResource("static/index.html")
val extensions = listOf("js", "css", "ico", "png", "jpg", "gif")
val spaPredicate = !(path("/api/**") or path("/error") or
pathExtension(extensions::contains))
val spaPredicate = !(path("/api/**") or path("/error"))
resource(spaPredicate, index)
}
----

View File

@@ -782,7 +782,7 @@ Java::
----
ClassPathResource index = new ClassPathResource("static/index.html");
List<String> extensions = List.of("js", "css", "ico", "png", "jpg", "gif");
RequestPredicate spaPredicate = path("/api/**").or(path("/error")).or(pathExtension(extensions::contains)).negate();
RequestPredicate spaPredicate = path("/api/**").or(path("/error")).negate();
RouterFunction<ServerResponse> redirectToIndex = route()
.resource(spaPredicate, index)
.build();
@@ -794,9 +794,7 @@ Kotlin::
----
val redirectToIndex = router {
val index = ClassPathResource("static/index.html")
val extensions = listOf("js", "css", "ico", "png", "jpg", "gif")
val spaPredicate = !(path("/api/**") or path("/error") or
pathExtension(extensions::contains))
val spaPredicate = !(path("/api/**") or path("/error"))
resource(spaPredicate, index)
}
----