public override void HandleApiRequest(IApiContext apiContext) { var configurationParser = new OpenWeatherMapConfigurationParser(); apiContext.Response = ExportStatusToJsonObject(); apiContext.Response.SetNamedString("Uri", configurationParser.GetUri().ToString()); }
private async Task <string> FetchWeatherData() { Uri uri = new OpenWeatherMapConfigurationParser().GetUri(); using (var httpClient = new HttpClient()) using (HttpResponseMessage result = await httpClient.GetAsync(uri)) { return(await result.Content.ReadAsStringAsync()); } }
private string FetchWeatherData() { Uri uri = new OpenWeatherMapConfigurationParser().GetUri(); _systemInformationService.Set("OpenWeatherMapService/Uri", uri.ToString()); var stopwatch = Stopwatch.StartNew(); try { using (var httpClient = new HttpClient()) using (HttpResponseMessage result = httpClient.GetAsync(uri).AsTask().Result) { return(result.Content.ReadAsStringAsync().AsTask().Result); } } finally { _systemInformationService.Set("OpenWeatherMapService/LastFetchDuration", stopwatch.Elapsed); } }