jellyfin/MediaBrowser.Api/HttpHandlers/ServerConfigurationHandler.cs

38 lines
1.1 KiB
C#
Raw Normal View History

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()
{
2012-09-11 18:20:12 +00:00
return Task.FromResult(Kernel.Instance.Configuration);
}
2012-09-04 19:23:15 +00:00
protected override async Task<ResponseInfo> GetResponseInfo()
2012-09-04 19:23:15 +00:00
{
var info = await base.GetResponseInfo().ConfigureAwait(false);
2012-09-04 19:23:15 +00:00
info.DateLastModified =
File.GetLastWriteTimeUtc(Kernel.Instance.ApplicationPaths.SystemConfigurationFilePath);
info.CacheDuration = TimeSpan.FromDays(7);
return info;
2012-09-04 19:23:15 +00:00
}
}
}