Added more magic to fancy. it now automatically figures our response for PUT and POST based on request ID.

file name sample uses HTTP GET instead of post
This commit is contained in:
kay.one 2013-08-25 22:14:55 -07:00
commit 4188946395
20 changed files with 135 additions and 198 deletions

View file

@ -1,5 +1,6 @@
using System;
using System.Linq;
using Nancy;
using NzbDrone.Api.Extensions;
using NzbDrone.Common.Composition;
using NzbDrone.Common.Messaging;
@ -16,10 +17,11 @@ namespace NzbDrone.Api.Commands
_messageAggregator = messageAggregator;
_container = container;
CreateResource = RunCommand;
Post["/"] = x => RunCommand(ReadResourceFromRequest());
}
private CommandResource RunCommand(CommandResource resource)
private Response RunCommand(CommandResource resource)
{
var commandType =
_container.GetImplementations(typeof(ICommand))
@ -29,7 +31,7 @@ namespace NzbDrone.Api.Commands
dynamic command = Request.Body.FromJson(commandType);
_messageAggregator.PublishCommand(command);
return resource;
return resource.AsResponse();
}
}
}