jellyfin-server/MediaBrowser.Api/HttpHandlers/UserHandler.cs
LukePulverenti Luke Pulverenti luke pulverenti 93b42641d2 Switched to MEF to register http handlers
2012-09-08 10:52:13 -04:00

30 lines
897 B
C#

using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Model.DTO;
using MediaBrowser.Model.Entities;
using System.ComponentModel.Composition;
using System.Net;
using System.Threading.Tasks;
namespace MediaBrowser.Api.HttpHandlers
{
[Export(typeof(BaseHandler))]
class UserHandler : BaseSerializationHandler<DTOUser>
{
public override bool HandlesRequest(HttpListenerRequest request)
{
return ApiService.IsApiUrlMatch("user", request);
}
protected override Task<DTOUser> GetObjectToSerialize()
{
string id = QueryString["id"];
User user = string.IsNullOrEmpty(id) ? ApiService.GetDefaultUser(false) : ApiService.GetUserById(id, false); ;
DTOUser dto = ApiService.GetDTOUser(user);
return Task.FromResult<DTOUser>(dto);
}
}
}