jellyfin/MediaBrowser.Api/HttpHandlers/ServerConfigurationHandler.cs
LukePulverenti Luke Pulverenti luke pulverenti d8c01ded6e made some improvements to the base http handler
2012-09-19 12:51:37 -04:00

38 lines
1.1 KiB
C#

using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Controller;
using MediaBrowser.Model.Configuration;
using System;
using System.ComponentModel.Composition;
using System.IO;
using System.Net;
using System.Threading.Tasks;
namespace MediaBrowser.Api.HttpHandlers
{
[Export(typeof(BaseHandler))]
class ServerConfigurationHandler : BaseSerializationHandler<ServerConfiguration>
{
public override bool HandlesRequest(HttpListenerRequest request)
{
return ApiService.IsApiUrlMatch("serverconfiguration", request);
}
protected override Task<ServerConfiguration> GetObjectToSerialize()
{
return Task.FromResult(Kernel.Instance.Configuration);
}
protected override async Task<ResponseInfo> GetResponseInfo()
{
var info = await base.GetResponseInfo().ConfigureAwait(false);
info.DateLastModified =
File.GetLastWriteTimeUtc(Kernel.Instance.ApplicationPaths.SystemConfigurationFilePath);
info.CacheDuration = TimeSpan.FromDays(7);
return info;
}
}
}