basic RSS fetch seems to be working.

download might still not work.
This commit is contained in:
kay.one 2013-04-27 17:25:28 -07:00
commit a1783a53a9
20 changed files with 186 additions and 22 deletions

View file

@ -0,0 +1,14 @@
using System;
using Nancy;
using NzbDrone.Api.ErrorManagement;
namespace NzbDrone.Api.REST
{
public class BadRequestException : ApiException
{
public BadRequestException(object content = null)
: base(HttpStatusCode.BadRequest, content)
{
}
}
}

View file

@ -25,6 +25,15 @@ namespace NzbDrone.Api.REST
protected ResourceValidator<TResource> SharedValidator { get; private set; }
protected void ValidateId(int id)
{
if (id <= 0)
{
throw new BadRequestException(id + " is not a valid ID");
}
}
protected RestModule(string modulePath)
: base(modulePath)
{
@ -42,6 +51,7 @@ namespace NzbDrone.Api.REST
_deleteResource = value;
Delete[ID_ROUTE] = options =>
{
ValidateId(options.Id);
DeleteResource((int)options.Id);
return new Response { StatusCode = HttpStatusCode.OK };
};
@ -56,12 +66,7 @@ namespace NzbDrone.Api.REST
_getResourceById = value;
Get[ID_ROUTE] = options =>
{
int id;
if (!Int32.TryParse(options.Id, out id))
{
throw new NotImplementedException();
}
ValidateId(options.Id);
var resource = GetResourceById((int)options.Id);
return resource.AsResponse();
};