aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2013-02-20 17:10:49 -0800
committerLuke <luke.pulverenti@gmail.com>2013-02-20 17:10:49 -0800
commit845554722efaed872948a9e0f7202e3ef52f1b6e (patch)
tree534ab2d11fe4824ed303bb01e885b330631b657e /MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs
parent2f142263f080f7b012a0ec2095d350ccf75b49b7 (diff)
parent14bbb6804718ef78a8118fe750896ba679e3b6cb (diff)
Merge pull request #1 from MediaBrowser/Repo
Repo
Diffstat (limited to 'MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs')
-rw-r--r--MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs53
1 files changed, 53 insertions, 0 deletions
diff --git a/MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs b/MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs
new file mode 100644
index 000000000..dc363956f
--- /dev/null
+++ b/MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs
@@ -0,0 +1,53 @@
+using MediaBrowser.Common.Net.Handlers;
+using MediaBrowser.Common.Plugins;
+using MediaBrowser.Controller;
+using MediaBrowser.Model.Plugins;
+using System;
+using System.ComponentModel.Composition;
+using System.Linq;
+using System.Net;
+using System.Threading.Tasks;
+
+namespace MediaBrowser.Api.HttpHandlers
+{
+ [Export(typeof(BaseHandler))]
+ public class PluginConfigurationHandler : BaseSerializationHandler<BasePluginConfiguration>
+ {
+ public override bool HandlesRequest(HttpListenerRequest request)
+ {
+ return ApiService.IsApiUrlMatch("pluginconfiguration", request);
+ }
+
+ private BasePlugin _plugin;
+ private BasePlugin Plugin
+ {
+ get
+ {
+ if (_plugin == null)
+ {
+ string name = QueryString["assemblyfilename"];
+
+ _plugin = Kernel.Instance.Plugins.First(p => p.AssemblyFileName.Equals(name, StringComparison.OrdinalIgnoreCase));
+ }
+
+ return _plugin;
+ }
+ }
+
+ protected override Task<BasePluginConfiguration> GetObjectToSerialize()
+ {
+ return Task.FromResult(Plugin.Configuration);
+ }
+
+ protected override async Task<ResponseInfo> GetResponseInfo()
+ {
+ var info = await base.GetResponseInfo().ConfigureAwait(false);
+
+ info.DateLastModified = Plugin.ConfigurationDateLastModified;
+
+ info.CacheDuration = TimeSpan.FromDays(7);
+
+ return info;
+ }
+ }
+}