mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 18:57:39 -07:00
basic RSS fetch seems to be working.
download might still not work.
This commit is contained in:
parent
182192e0ba
commit
a1783a53a9
20 changed files with 186 additions and 22 deletions
14
NzbDrone.Api/REST/BadRequestException.cs
Normal file
14
NzbDrone.Api/REST/BadRequestException.cs
Normal 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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue