From 25b9e53ca607a679075148f70c222a0428153be9 Mon Sep 17 00:00:00 2001 From: Taylor Howell Date: Sat, 18 Nov 2023 12:04:23 -0600 Subject: [PATCH] .net env is wierd --- Program.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Program.cs b/Program.cs index 9b0660a..9799891 100644 --- a/Program.cs +++ b/Program.cs @@ -9,6 +9,11 @@ var builder = WebApplication.CreateBuilder(args); +var appsetting = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json") + .Build(); + // Add services to the container. // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); @@ -16,9 +21,11 @@ var app = builder.Build(); -var apiKey = Environment.GetEnvironmentVariable("API_KEY"); +var apiKey = appsetting["API_KEY"]; var valkApiKey = "some key"; +Debug.WriteLine("\napi key: " + apiKey + "\n"); + long minuteCountWaitTime = 5; StateMachinesController? stateMachinesController = new StateMachinesController(minuteCountWaitTime); @@ -43,6 +50,7 @@ app.MapGet("/", (HttpContext ctx) => { + ctx.Response.Headers.Add("Content-Type", "application/json"); ctx.Response.StatusCode = 200; return JsonSerializer.Serialize(new message("Hello World!")); });