mirror of
https://github.com/jcreek/CityFinder.git
synced 2026-07-12 18:33:44 +00:00
feat(*): Perform initial setup
This involves setting up the config file and the httpclient.
This commit is contained in:
@@ -5,6 +5,24 @@
|
|||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="appsettings.json" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="appsettings.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="5.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="5.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="5.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Update="Program.cs">
|
<Compile Update="Program.cs">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
|||||||
@@ -29,7 +29,26 @@ namespace CityFinder
|
|||||||
{
|
{
|
||||||
internal class Program
|
internal class Program
|
||||||
{
|
{
|
||||||
|
private static readonly HttpClient client = new HttpClient();
|
||||||
|
private static IConfigurationRoot config;
|
||||||
private static async Task Main(string[] args)
|
private static async Task Main(string[] args)
|
||||||
{
|
{
|
||||||
|
InitialSetup();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This method sets up the json config file and sets the user-agent header on the HttpClient.
|
||||||
|
/// </summary>
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"GoogleMapsGeocodeApiKey": "your-key-goes-here"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user