Initial work on getting minimal API to work
This commit is contained in:
@@ -3,7 +3,6 @@ using AS1024.GeoFeed.Core.Interfaces;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using AS1024.GeoFeed.Models;
|
||||
using System.Text;
|
||||
using AS1024.GeoFeed.Core.GeoFeedLocalCache;
|
||||
using AS1024.GeoFeed.Core.Tools;
|
||||
|
||||
namespace AS1024.GeoFeed.Controllers
|
||||
@@ -18,16 +17,16 @@ namespace AS1024.GeoFeed.Controllers
|
||||
private readonly IMemoryCache memoryCache;
|
||||
private readonly IWebHostEnvironment environment;
|
||||
private readonly ILogger<GeofeedController> logger;
|
||||
private readonly GeoFeedCacheDbContext dbContext;
|
||||
private readonly IGeoFeedPersistentCacheProvider geoFeedPersistentCache;
|
||||
private const string GeoFeedCacheKey = "GeoFeedData";
|
||||
|
||||
public GeofeedController(IGeoFeedProvider builder,
|
||||
IMemoryCache memoryCache,
|
||||
IWebHostEnvironment environment,
|
||||
ILogger<GeofeedController> logger,
|
||||
GeoFeedCacheDbContext dbContext) {
|
||||
IGeoFeedPersistentCacheProvider geoFeedPersistentCache) {
|
||||
this.logger = logger;
|
||||
this.dbContext = dbContext;
|
||||
this.geoFeedPersistentCache = geoFeedPersistentCache;
|
||||
this.builder = builder;
|
||||
this.memoryCache = memoryCache;
|
||||
this.environment = environment;
|
||||
@@ -54,10 +53,7 @@ namespace AS1024.GeoFeed.Controllers
|
||||
} catch (HttpRequestException ex)
|
||||
{
|
||||
logger.LogWarning($"Temporary failure of retrieving GeoData from upstream. {ex}");
|
||||
var results =
|
||||
dbContext.GeoFeedCacheEntries.ToList();
|
||||
List<IPGeoFeed> cachedData = [];
|
||||
results.ForEach(cachedData.Add);
|
||||
var cachedData = geoFeedPersistentCache.GetGeoFeed();
|
||||
return ReturnFile(cachedData);
|
||||
}
|
||||
|
||||
@@ -73,6 +69,12 @@ namespace AS1024.GeoFeed.Controllers
|
||||
private IActionResult ReturnFile(List<IPGeoFeed>? feed)
|
||||
{
|
||||
string csvContent = feed.ToGeoFeedCsv(); // Assuming ToGeoFeedCsv() returns a string in CSV format.
|
||||
return ReturnFile(csvContent);
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
private IActionResult ReturnFile(string csvContent)
|
||||
{
|
||||
byte[] contentBytes = Encoding.UTF8.GetBytes(csvContent);
|
||||
string contentType = "text/csv";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user