From 93b42641d23cf675b74d4bdaf6d6ece07fbb8900 Mon Sep 17 00:00:00 2001 From: LukePulverenti Luke Pulverenti luke pulverenti Date: Sat, 8 Sep 2012 10:52:13 -0400 Subject: [PATCH] Switched to MEF to register http handlers --- MediaBrowser.Api/ApiService.cs | 6 + MediaBrowser.Api/HttpHandlers/AudioHandler.cs | 13 +- .../HttpHandlers/BaseMediaHandler.cs | 12 +- MediaBrowser.Api/HttpHandlers/GenreHandler.cs | 8 ++ .../HttpHandlers/GenresHandler.cs | 8 ++ MediaBrowser.Api/HttpHandlers/ImageHandler.cs | 8 ++ MediaBrowser.Api/HttpHandlers/ItemHandler.cs | 8 ++ .../HttpHandlers/ItemListHandler.cs | 8 ++ .../HttpHandlers/PersonHandler.cs | 8 ++ .../HttpHandlers/PluginAssemblyHandler.cs | 13 +- .../PluginConfigurationHandler.cs | 16 ++- .../HttpHandlers/PluginsHandler.cs | 16 ++- .../ServerConfigurationHandler.cs | 16 ++- .../HttpHandlers/StudioHandler.cs | 8 ++ .../HttpHandlers/StudiosHandler.cs | 8 ++ .../HttpHandlers/UserAuthenticationHandler.cs | 8 ++ MediaBrowser.Api/HttpHandlers/UserHandler.cs | 8 ++ MediaBrowser.Api/HttpHandlers/UsersHandler.cs | 8 ++ MediaBrowser.Api/HttpHandlers/VideoHandler.cs | 15 ++- .../HttpHandlers/WeatherHandler.cs | 14 +- MediaBrowser.Api/HttpHandlers/YearHandler.cs | 8 ++ MediaBrowser.Api/HttpHandlers/YearsHandler.cs | 8 ++ MediaBrowser.Api/Plugin.cs | 120 +----------------- MediaBrowser.Common/Kernel/BaseKernel.cs | 32 +++++ .../Net/Handlers/BaseHandler.cs | 8 +- .../Net/Handlers/StaticFileHandler.cs | 9 +- 26 files changed, 240 insertions(+), 154 deletions(-) diff --git a/MediaBrowser.Api/ApiService.cs b/MediaBrowser.Api/ApiService.cs index ab12a350f4..6b3c00ee25 100644 --- a/MediaBrowser.Api/ApiService.cs +++ b/MediaBrowser.Api/ApiService.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using System.Net; namespace MediaBrowser.Api { @@ -374,5 +375,10 @@ namespace MediaBrowser.Api LastLoginDate = user.LastLoginDate }; } + + public static bool IsApiUrlMatch(string url, HttpListenerRequest request) + { + return request.Url.LocalPath.EndsWith(url, StringComparison.OrdinalIgnoreCase); + } } } diff --git a/MediaBrowser.Api/HttpHandlers/AudioHandler.cs b/MediaBrowser.Api/HttpHandlers/AudioHandler.cs index f0d86ab37e..a01368635c 100644 --- a/MediaBrowser.Api/HttpHandlers/AudioHandler.cs +++ b/MediaBrowser.Api/HttpHandlers/AudioHandler.cs @@ -1,15 +1,24 @@ -using System.Collections.Generic; +using MediaBrowser.Common.Net.Handlers; +using MediaBrowser.Model.Entities; +using System.Collections.Generic; +using System.ComponentModel.Composition; using System.IO; using System.Linq; -using MediaBrowser.Model.Entities; +using System.Net; namespace MediaBrowser.Api.HttpHandlers { /// /// Supported output formats are: mp3,flac,ogg,wav,asf,wma,aac /// + [Export(typeof(BaseHandler))] public class AudioHandler : BaseMediaHandler