Append when the GeoFeed is retrieved and if it was generated from in memory cache
This commit is contained in:
@@ -36,10 +36,12 @@ namespace AS1024.GeoFeed.Controllers
|
||||
[Route("")]
|
||||
public async Task<IActionResult> Get()
|
||||
{
|
||||
bool isCached = true;
|
||||
try
|
||||
{
|
||||
if (!memoryCache.TryGetValue(GeoFeedCacheKey, out List<IPGeoFeed>? feed))
|
||||
{
|
||||
isCached = false;
|
||||
feed = await builder.GetGeoFeedData();
|
||||
if (environment.IsProduction())
|
||||
{
|
||||
@@ -49,7 +51,7 @@ namespace AS1024.GeoFeed.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
return ReturnFile(feed);
|
||||
return ReturnFile(feed, isCached);
|
||||
} catch (HttpRequestException ex)
|
||||
{
|
||||
logger.LogWarning($"Temporary failure of retrieving GeoData from upstream. {ex}");
|
||||
@@ -66,9 +68,9 @@ namespace AS1024.GeoFeed.Controllers
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
private IActionResult ReturnFile(List<IPGeoFeed>? feed)
|
||||
private IActionResult ReturnFile(List<IPGeoFeed>? feed, bool isCached = false)
|
||||
{
|
||||
string csvContent = feed.ToGeoFeedCsv(); // Assuming ToGeoFeedCsv() returns a string in CSV format.
|
||||
string csvContent = feed.ToGeoFeedCsv(true, isCached); // Assuming ToGeoFeedCsv() returns a string in CSV format.
|
||||
return ReturnFile(csvContent);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user