You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.1 KiB
37 lines
1.1 KiB
using System;
|
|
using System.Threading.Tasks;
|
|
using MediaBrowser.Common.Net.Handlers;
|
|
using MediaBrowser.Controller;
|
|
using MediaBrowser.Model.Weather;
|
|
|
|
namespace MediaBrowser.Api.HttpHandlers
|
|
{
|
|
class WeatherHandler : BaseSerializationHandler<WeatherInfo>
|
|
{
|
|
protected override Task<WeatherInfo> GetObjectToSerialize()
|
|
{
|
|
// If a specific zip code was requested on the query string, use that. Otherwise use the value from configuration
|
|
|
|
string zipCode = QueryString["zipcode"];
|
|
|
|
if (string.IsNullOrWhiteSpace(zipCode))
|
|
{
|
|
zipCode = Kernel.Instance.Configuration.WeatherZipCode;
|
|
}
|
|
|
|
return Kernel.Instance.WeatherClient.GetWeatherInfoAsync(zipCode);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tell the client to cache the weather info for 15 minutes
|
|
/// </summary>
|
|
public override TimeSpan CacheDuration
|
|
{
|
|
get
|
|
{
|
|
return TimeSpan.FromMinutes(15);
|
|
}
|
|
}
|
|
}
|
|
}
|