in dotnet/dotnet-guestbook/src/frontend/Controllers/HomeController.cs [30:53]
public async Task<IActionResult> Index()
{
_logger.LogInformation($"Getting all messages");
// Get the entries from the backend
try
{
var httpClient = _factory.CreateClient();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
// TODO - Good spot for adding a logpoint to get the backend address
_logger.LogInformation($"Making a request to {_envConfig.BackendAddress}");
var response = await httpClient.GetAsync(_envConfig.BackendAddress);
response.EnsureSuccessStatusCode();
var entries = await response.Content.ReadAsAsync<IEnumerable<GuestbookEntry>>();
return View(entries);
}
catch (Exception e)
{
_logger.LogError(e.ToString());
return View();
}
}