diff --git a/CityFinder/CityFinder.csproj b/CityFinder/CityFinder.csproj
index 5d69b21..9689360 100644
--- a/CityFinder/CityFinder.csproj
+++ b/CityFinder/CityFinder.csproj
@@ -5,6 +5,24 @@
net5.0
+
+
+
+
+
+
+ PreserveNewest
+
+
+
+
+
+
+
+
+
+
+
PreserveNewest
diff --git a/CityFinder/Program.cs b/CityFinder/Program.cs
index e314632..7530f5f 100644
--- a/CityFinder/Program.cs
+++ b/CityFinder/Program.cs
@@ -29,7 +29,26 @@ namespace CityFinder
{
internal class Program
{
+ private static readonly HttpClient client = new HttpClient();
+ private static IConfigurationRoot config;
private static async Task Main(string[] args)
{
+ InitialSetup();
+
+ ///
+ /// This method sets up the json config file and sets the user-agent header on the HttpClient.
+ ///
+ private static void InitialSetup()
+ {
+ // Set up handling json config files
+ IConfigurationBuilder builder = new ConfigurationBuilder()
+ .AddJsonFile($"appsettings.json", true, true)
+ .AddEnvironmentVariables();
+ config = builder.Build();
+
+ // Set default user-agent on the HttpClient to enable using the Google API from code
+ client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36");
}
+ }
+ }
}
diff --git a/CityFinder/appsettings.json b/CityFinder/appsettings.json
new file mode 100644
index 0000000..b72dcc6
--- /dev/null
+++ b/CityFinder/appsettings.json
@@ -0,0 +1,3 @@
+{
+ "GoogleMapsGeocodeApiKey": "your-key-goes-here"
+}