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

41 lines
1.1 KiB
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))]
public class ItemHandler : BaseSerializationHandler<DTOBaseItem>
{
public override bool HandlesRequest(HttpListenerRequest request)
{
return ApiService.IsApiUrlMatch("item", request);
}
protected override Task<DTOBaseItem> GetObjectToSerialize()
{
User user = ApiService.GetUserById(QueryString["userid"], true);
BaseItem item = ItemToSerialize;
if (item == null)
{
return null;
}
return ApiService.GetDTOBaseItem(item, user);
}
protected virtual BaseItem ItemToSerialize
{
get
{
return ApiService.GetItemById(QueryString["id"]);
}
}
}
}