diff --git a/Api/ProductsGet.cs b/Api/ProductsGet.cs new file mode 100644 index 0000000..8a4f092 --- /dev/null +++ b/Api/ProductsGet.cs @@ -0,0 +1,25 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Azure.WebJobs; +using Microsoft.Azure.WebJobs.Extensions.Http; +using System.Threading.Tasks; + +namespace Api; + +public class ProductsGet +{ + private readonly IProductData productData; + + public ProductsGet(IProductData productData) + { + this.productData = productData; + } + + [FunctionName("ProductsGet")] + public async Task Run( + [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "products")] HttpRequest req) + { + var products = await productData.GetProducts(); + return new OkObjectResult(products); + } +} \ No newline at end of file diff --git a/Api/Properties/launchSettings.json b/Api/Properties/launchSettings.json index e0576c6..1a072a9 100644 --- a/Api/Properties/launchSettings.json +++ b/Api/Properties/launchSettings.json @@ -1,4 +1,8 @@ { - "profiles": { + "profiles": { + "Api": { + "commandName": "Project", + "commandLineArgs": "start --cors *" } + } } \ No newline at end of file diff --git a/ShoppingList.sln b/ShoppingList.sln index c403c00..3f286a2 100644 --- a/ShoppingList.sln +++ b/ShoppingList.sln @@ -62,4 +62,4 @@ Global GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {EC9ADCA0-AF9C-4DCA-971A-A96B676B5A8A} EndGlobalSection -EndGlobal \ No newline at end of file +EndGlobal