Skip to content

Commit

Permalink
Fix REST client to build "id" URLs correctly.
Browse files Browse the repository at this point in the history
See also #1209.
  • Loading branch information
s-ludwig committed Sep 13, 2015
1 parent 3a8a94d commit 09ee6a2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/vibe/web/rest.d
Expand Up @@ -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;
Expand Down
20 changes: 20 additions & 0 deletions tests/restclient/source/app.d
Expand Up @@ -4,6 +4,8 @@ import vibe.vibe;

interface ITestAPI
{
@property ISub sub();

@method(HTTPMethod.POST) @path("other/path")
string info();
string getInfo();
Expand All @@ -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;
Expand All @@ -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);
}
Expand Down

0 comments on commit 09ee6a2

Please sign in to comment.