From bfe3fe672fe4a49cac7a7de61a3b774315cc54cd Mon Sep 17 00:00:00 2001 From: hllshiro <18037517667@163.com> Date: Mon, 9 Oct 2023 22:22:38 +0800 Subject: [PATCH] add standard mime type (#19) --- src/main/java/run/halo/feed/FeedPluginEndpoint.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/run/halo/feed/FeedPluginEndpoint.java b/src/main/java/run/halo/feed/FeedPluginEndpoint.java index dd2c8f2..46a242d 100644 --- a/src/main/java/run/halo/feed/FeedPluginEndpoint.java +++ b/src/main/java/run/halo/feed/FeedPluginEndpoint.java @@ -4,6 +4,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.http.MediaType; import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.RequestPredicate; import org.springframework.web.reactive.function.server.RouterFunction; import org.springframework.web.reactive.function.server.RouterFunctions; import org.springframework.web.reactive.function.server.ServerResponse; @@ -23,13 +24,17 @@ public class FeedPluginEndpoint { @Bean RouterFunction sitemapRouterFunction() { - return RouterFunctions.route(GET("/feed.xml").and(accept(MediaType.TEXT_XML)), + RequestPredicate requestPredicate = accept( + MediaType.TEXT_XML, + MediaType.APPLICATION_RSS_XML + ); + return RouterFunctions.route(GET("/feed.xml").and(requestPredicate), feedService::allFeed) - .andRoute(GET("/rss.xml").and(accept(MediaType.TEXT_XML)), + .andRoute(GET("/rss.xml").and(requestPredicate), feedService::allFeed) - .andRoute(GET("/feed/categories/{category}.xml").and(accept(MediaType.TEXT_XML)), + .andRoute(GET("/feed/categories/{category}.xml").and(requestPredicate), request -> feedService.categoryFeed(request, request.pathVariable("category"))) - .andRoute(GET("/feed/authors/{author}.xml").and(accept(MediaType.TEXT_XML)), + .andRoute(GET("/feed/authors/{author}.xml").and(requestPredicate), request -> feedService.authorFeed(request, request.pathVariable("author"))); } } \ No newline at end of file