From 79767aa7bf513862beeaaeba23e1a640dd19442c Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 16 Feb 2014 21:58:09 -0800 Subject: [PATCH] Redirect /api/missing to new endpoint --- src/NzbDrone.Api/NzbDrone.Api.csproj | 1 + .../Wanted/LegacyMissingModule.cs | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/NzbDrone.Api/Wanted/LegacyMissingModule.cs diff --git a/src/NzbDrone.Api/NzbDrone.Api.csproj b/src/NzbDrone.Api/NzbDrone.Api.csproj index a4f7bf194..3305a880d 100644 --- a/src/NzbDrone.Api/NzbDrone.Api.csproj +++ b/src/NzbDrone.Api/NzbDrone.Api.csproj @@ -151,6 +151,7 @@ + diff --git a/src/NzbDrone.Api/Wanted/LegacyMissingModule.cs b/src/NzbDrone.Api/Wanted/LegacyMissingModule.cs new file mode 100644 index 000000000..1fe0bb6ca --- /dev/null +++ b/src/NzbDrone.Api/Wanted/LegacyMissingModule.cs @@ -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('&'); + } + } +}