Redirect /api/missing to new endpoint

This commit is contained in:
Mark McDowall 2014-02-16 21:58:09 -08:00
parent 45f748cf03
commit 79767aa7bf
2 changed files with 35 additions and 0 deletions

View File

@ -151,6 +151,7 @@
<Compile Include="Mapping\ResourceMappingException.cs" />
<Compile Include="Mapping\ValueInjectorExtensions.cs" />
<Compile Include="Wanted\CutoffModule.cs" />
<Compile Include="Wanted\LegacyMissingModule.cs" />
<Compile Include="Wanted\MissingModule.cs" />
<Compile Include="Config\NamingSampleResource.cs" />
<Compile Include="NzbDroneRestModuleWithSignalR.cs" />

View File

@ -0,0 +1,34 @@
using System;
using System.Text;
using Nancy;
namespace NzbDrone.Api.Wanted
{
class LegacyMissingModule : NzbDroneApiModule
{
public LegacyMissingModule() : base("missing")
{
Get["/"] = x =>
{
string queryString = ConvertQueryParams(Request.Query);
var url = String.Format("/api/wanted/missing?{0}", queryString);
return Response.AsRedirect(url);
};
}
private string ConvertQueryParams(DynamicDictionary query)
{
var sb = new StringBuilder();
foreach (var key in query)
{
var value = query[key];
sb.AppendFormat("&{0}={1}", key, value);
}
return sb.ToString().Trim('&');
}
}
}