feed controller: add cache control for feed result
This commit is contained in:
@@ -27,6 +27,7 @@ package net.runelite.http.service.feed;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.http.api.feed.FeedItem;
|
||||
import net.runelite.http.api.feed.FeedResult;
|
||||
@@ -34,6 +35,8 @@ import net.runelite.http.service.feed.blog.BlogService;
|
||||
import net.runelite.http.service.feed.osrsnews.OSRSNewsService;
|
||||
import net.runelite.http.service.feed.twitter.TwitterService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.CacheControl;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -93,8 +96,16 @@ public class FeedController
|
||||
}
|
||||
|
||||
@RequestMapping
|
||||
public FeedResult getFeed()
|
||||
public ResponseEntity<FeedResult> getFeed()
|
||||
{
|
||||
return feedResult;
|
||||
if (feedResult == null)
|
||||
{
|
||||
return ResponseEntity.notFound()
|
||||
.build();
|
||||
}
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.cacheControl(CacheControl.maxAge(10, TimeUnit.MINUTES).cachePublic())
|
||||
.body(feedResult);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user