aboutsummaryrefslogtreecommitdiff
path: root/Backend
diff options
context:
space:
mode:
Diffstat (limited to 'Backend')
-rw-r--r--Backend/ListStops.cs9
1 files changed, 9 insertions, 0 deletions
diff --git a/Backend/ListStops.cs b/Backend/ListStops.cs
index 93b6a48..b6f9ab4 100644
--- a/Backend/ListStops.cs
+++ b/Backend/ListStops.cs
@@ -2,6 +2,7 @@ using Microsoft.Azure.Functions.Worker;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Costasdev.VigoTransitApi;
+using Costasdev.VigoTransitApi.Types;
namespace Costasdev.UrbanoVigoWeb;
@@ -9,6 +10,8 @@ public class ListStops
{
private readonly VigoTransitApiClient _api;
+ public List<Stop>? Stops { get; set; } = null;
+
public ListStops(HttpClient http)
{
_api = new VigoTransitApiClient(http);
@@ -17,6 +20,12 @@ public class ListStops
[Function("ListStops")]
public async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequest req)
{
+ // Get stops from cache
+ if (Stops != null)
+ {
+ return new OkObjectResult(Stops);
+ }
+
try
{
var stops = await _api.GetStops();