浏览代码

Added a default user handler

LukePulverenti Luke Pulverenti luke pulverenti 12 年之前
父节点
当前提交
f428c976aa

+ 21 - 0
MediaBrowser.Api/HttpHandlers/DefaultUserHandler.cs

@@ -0,0 +1,21 @@
+using System.Linq;
+using System.Threading.Tasks;
+using MediaBrowser.Common.Net.Handlers;
+using MediaBrowser.Controller;
+using MediaBrowser.Model.DTO;
+using MediaBrowser.Model.Entities;
+
+namespace MediaBrowser.Api.HttpHandlers
+{
+    class DefaultUserHandler : BaseSerializationHandler<DTOUser>
+    {
+        protected override Task<DTOUser> GetObjectToSerialize()
+        {
+            User user = Kernel.Instance.Users.FirstOrDefault();
+
+            DTOUser dto = ApiService.GetDTOUser(user);
+
+            return Task.FromResult<DTOUser>(dto);
+        }
+    }
+}

+ 1 - 0
MediaBrowser.Api/MediaBrowser.Api.csproj

@@ -57,6 +57,7 @@
     <Compile Include="ApiService.cs" />
     <Compile Include="HttpHandlers\AudioHandler.cs" />
     <Compile Include="HttpHandlers\BaseMediaHandler.cs" />
+    <Compile Include="HttpHandlers\DefaultUserHandler.cs" />
     <Compile Include="HttpHandlers\GenreHandler.cs" />
     <Compile Include="HttpHandlers\GenresHandler.cs" />
     <Compile Include="HttpHandlers\ImageHandler.cs" />

+ 5 - 1
MediaBrowser.Api/Plugin.cs

@@ -105,10 +105,14 @@ namespace MediaBrowser.Api
             {
                 return new WeatherHandler();
             }
-            else if (localPath.EndsWith("/api/cerverconfiguration", StringComparison.OrdinalIgnoreCase))
+            else if (localPath.EndsWith("/api/serverconfiguration", StringComparison.OrdinalIgnoreCase))
             {
                 return new ServerConfigurationHandler();
             }
+            else if (localPath.EndsWith("/api/defaultuser", StringComparison.OrdinalIgnoreCase))
+            {
+                return new DefaultUserHandler();
+            }
 
             return null;
         }