diff options
| author | Ariel Costas Guerrero <94913521+arielcostas@users.noreply.github.com> | 2024-08-25 23:12:48 +0200 |
|---|---|---|
| committer | Ariel Costas Guerrero <94913521+arielcostas@users.noreply.github.com> | 2024-08-25 23:12:48 +0200 |
| commit | dc20c2ba8377a90a3170642c9b3df6cd5166ad72 (patch) | |
| tree | 744a6ce5076fc3378ded6a08acca122637229afc /Backend/ListStops.cs | |
Initial commit
Diffstat (limited to 'Backend/ListStops.cs')
| -rw-r--r-- | Backend/ListStops.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Backend/ListStops.cs b/Backend/ListStops.cs new file mode 100644 index 0000000..93b6a48 --- /dev/null +++ b/Backend/ListStops.cs @@ -0,0 +1,30 @@ +using Microsoft.Azure.Functions.Worker; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Costasdev.VigoTransitApi; + +namespace Costasdev.UrbanoVigoWeb; + +public class ListStops +{ + private readonly VigoTransitApiClient _api; + + public ListStops(HttpClient http) + { + _api = new VigoTransitApiClient(http); + } + + [Function("ListStops")] + public async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequest req) + { + try + { + var stops = await _api.GetStops(); + return new OkObjectResult(stops); + } + catch (InvalidOperationException) + { + return new BadRequestObjectResult("Stop not found"); + } + } +} |
