From 09ee6a27f9a57a4a9757dcc8aff073148be94d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Sun, 13 Sep 2015 10:38:44 +0200 Subject: [PATCH] Fix REST client to build "id" URLs correctly. See also #1209. --- source/vibe/web/rest.d | 2 +- tests/restclient/source/app.d | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/source/vibe/web/rest.d b/source/vibe/web/rest.d index 0c489c1b30..0fedcea7f9 100644 --- a/source/vibe/web/rest.d +++ b/source/vibe/web/rest.d @@ -1109,7 +1109,7 @@ private string genClientBody(alias Func)() { request_str = q{ if (m_settings.stripTrailingUnderscore && url__.endsWith("_")) url__ = url__[0 .. $-1]; - url__ = %s ~ adjustMethodStyle(url__, m_methodStyle); + url__ = concatURL(%s, adjustMethodStyle(url__, m_methodStyle)); }.format(url_prefix); } else { import std.array : split; diff --git a/tests/restclient/source/app.d b/tests/restclient/source/app.d index 5aa6ab4136..caf1d848f0 100644 --- a/tests/restclient/source/app.d +++ b/tests/restclient/source/app.d @@ -4,6 +4,8 @@ import vibe.vibe; interface ITestAPI { + @property ISub sub(); + @method(HTTPMethod.POST) @path("other/path") string info(); string getInfo(); @@ -15,20 +17,36 @@ interface ITestAPI int testID1(int _id); @path("idtest2") int testID2(int id); // the special "id" parameter + int get(int id); // the special "id" parameter on "/"" path int testKeyword(int body_, int const_); } +interface ISub { + int get(int id); +} + class TestAPI : ITestAPI { + SubAPI m_sub; + + this() { m_sub = new SubAPI; } + + @property SubAPI sub() { return m_sub; } + string getInfo() { return "description"; } string info() { return "description2"; } string customParameters(string _param, string _param2) { return _param ~ _param2; } int customParameters2(int _param, bool _param2) { return _param2 ? _param : -_param; } int testID1(int _id) { return _id; } int testID2(int id) { return id; } + int get(int id) { return id; } int testKeyword(int body_, int const_) { return body_ + const_; } } +class SubAPI : ISub { + int get(int id) { return id; } +} + void runTest() { auto router = new URLRouter; @@ -47,6 +65,8 @@ void runTest() assert(api.customParameters2(10, true) == 10); assert(api.testID1(2) == 2); assert(api.testID2(3) == 3); + assert(api.get(4) == 4); + assert(api.sub.get(5) == 5); assert(api.testKeyword(3, 4) == 7); exitEventLoop(true); }