jellyfin/MediaBrowser.Api/HttpHandlers/ItemHandler.cs

36 lines
1.0 KiB
C#
Raw Normal View History

2012-09-07 16:17:39 +00:00
using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.DTO;
using System.ComponentModel.Composition;
using System.Net;
2012-09-07 16:17:39 +00:00
using System.Threading.Tasks;
2012-07-12 06:55:27 +00:00
namespace MediaBrowser.Api.HttpHandlers
{
2012-09-09 18:32:51 +00:00
/// <summary>
/// Provides a handler to retrieve a single item
/// </summary>
[Export(typeof(BaseHandler))]
2012-09-02 05:30:25 +00:00
public class ItemHandler : BaseSerializationHandler<DTOBaseItem>
2012-07-12 06:55:27 +00:00
{
public override bool HandlesRequest(HttpListenerRequest request)
{
return ApiService.IsApiUrlMatch("item", request);
}
2012-08-22 02:50:59 +00:00
protected override Task<DTOBaseItem> GetObjectToSerialize()
2012-07-12 06:55:27 +00:00
{
2012-09-07 16:17:39 +00:00
User user = ApiService.GetUserById(QueryString["userid"], true);
2012-09-09 18:32:51 +00:00
BaseItem item = ApiService.GetItemById(QueryString["id"]);
if (item == null)
{
return null;
2012-07-12 06:55:27 +00:00
}
2012-08-22 02:50:59 +00:00
return ApiService.GetDTOBaseItem(item, user);
2012-07-12 06:55:27 +00:00
}
}
}