2012-09-08 14:52:13 +00:00
|
|
|
|
using MediaBrowser.Common.Net.Handlers;
|
2012-09-02 13:45:02 +00:00
|
|
|
|
using MediaBrowser.Controller;
|
|
|
|
|
using MediaBrowser.Model.Configuration;
|
2012-09-08 14:52:13 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel.Composition;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Threading.Tasks;
|
2012-09-02 13:45:02 +00:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Api.HttpHandlers
|
|
|
|
|
{
|
2012-09-08 14:52:13 +00:00
|
|
|
|
[Export(typeof(BaseHandler))]
|
2012-09-02 13:45:02 +00:00
|
|
|
|
class ServerConfigurationHandler : BaseSerializationHandler<ServerConfiguration>
|
|
|
|
|
{
|
2012-09-08 14:52:13 +00:00
|
|
|
|
public override bool HandlesRequest(HttpListenerRequest request)
|
|
|
|
|
{
|
|
|
|
|
return ApiService.IsApiUrlMatch("serverconfiguration", request);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-02 13:45:02 +00:00
|
|
|
|
protected override Task<ServerConfiguration> GetObjectToSerialize()
|
|
|
|
|
{
|
|
|
|
|
return Task.FromResult<ServerConfiguration>(Kernel.Instance.Configuration);
|
|
|
|
|
}
|
2012-09-04 19:23:15 +00:00
|
|
|
|
|
|
|
|
|
public override TimeSpan CacheDuration
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return TimeSpan.FromDays(7);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override Task<DateTime?> GetLastDateModified()
|
|
|
|
|
{
|
|
|
|
|
return Task.FromResult<DateTime?>(File.GetLastWriteTimeUtc(Kernel.Instance.ApplicationPaths.SystemConfigurationFilePath));
|
|
|
|
|
}
|
2012-09-02 13:45:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|