Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vibe.web.web: Allow to return strings #1854

Merged
merged 2 commits into from Apr 3, 2018
Merged

Conversation

@wilzbach
Copy link
Member

@wilzbach wilzbach commented Jul 18, 2017

Split-off from #1697

@wilzbach wilzbach mentioned this pull request Jul 18, 2017
0 of 3 tasks complete
@@ -964,6 +964,8 @@ private void handleRequest(string M, alias overload, C, ERROR...)(HTTPServerRequ
} else {
res.writeBody(ret);
}
} else static if (is(RET : string)) {
res.writeBody(ret);
} else {
static assert(is(RET == void), M~": Only InputStream, Json and void are supported as return types for route methods.");

This comment has been minimized.

@WebFreak001

WebFreak001 Jul 25, 2017
Contributor

Don't forget to include string in the error message

@wilzbach wilzbach force-pushed the wilzbach:jsonify-web3 branch from 519f555 to ba02148 Oct 10, 2017
@wilzbach
Copy link
Member Author

@wilzbach wilzbach commented Oct 10, 2017

Don't forget to include string in the error message

Thanks. Added!

@wilzbach
Copy link
Member Author

@wilzbach wilzbach commented Nov 30, 2017

@s-ludwig anything blocking this? Returning a string happens often enough, s.t. imho it justifies the convenience and also this is just an added bonus as a couple of return types (InputStream and Json are already accepted).

@wilzbach wilzbach force-pushed the wilzbach:jsonify-web3 branch from ba02148 to 4258cfa Apr 2, 2018
@wilzbach
Copy link
Member Author

@wilzbach wilzbach commented Apr 2, 2018

Ping @s-ludwig - I think this is a trivial, non-controversial addition and helps a lot of people as returning string is a frequent use case.

@WebFreak001
Copy link
Contributor

@WebFreak001 WebFreak001 commented Apr 2, 2018

@s-ludwig merge pls, this is really useful and further changes can be done afterwards

@@ -1020,8 +1029,10 @@ private void handleRequest(string M, alias overload, C, ERROR...)(HTTPServerRequ
} else {
res.writeBody(ret);
}
} else static if (is(RET : string)) {

This comment has been minimized.

@s-ludwig

s-ludwig Apr 2, 2018
Member

const(char)[] is sufficient here.

} else {
static assert(is(RET == void), M~": Only InputStream, Json and void are supported as return types for route methods.");
static assert(is(RET == void), M~": Only InputStream, Json, string and void are supported as return types for route methods.");

This comment has been minimized.

@s-ludwig

s-ludwig Apr 2, 2018
Member

Would be nice to add const(ubyte)[] here, too (and change to const(char)[] if adjusted).

@s-ludwig
Copy link
Member

@s-ludwig s-ludwig commented Apr 2, 2018

Couldn't find a compelling argument against this, especially considering that ubyte[] and char[] are already supported by writeBody in a similar way. Would just be nice to loosen this up to const(char)[] instead of string.

@wilzbach wilzbach force-pushed the wilzbach:jsonify-web3 branch from 109297b to d1d1cc3 Apr 2, 2018
@wilzbach
Copy link
Member Author

@wilzbach wilzbach commented Apr 2, 2018

Would just be nice to loosen this up to const(char)[] instead of string.

Good idea. Done.

@wilzbach wilzbach force-pushed the wilzbach:jsonify-web3 branch from d1d1cc3 to 57739e7 Apr 2, 2018
@dlang-bot dlang-bot merged commit e42f30b into vibe-d:master Apr 3, 2018
3 checks passed
3 checks passed
codecov/patch Coverage not affected when comparing b9985f4...72e9c3b
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants