-
Notifications
You must be signed in to change notification settings - Fork 284
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
Conversation
web/vibe/web/web.d
Outdated
@@ -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."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to include string in the error message
519f555
to
ba02148
Compare
Thanks. Added! |
@s-ludwig anything blocking this? Returning a |
Ping @s-ludwig - I think this is a trivial, non-controversial addition and helps a lot of people as returning |
@s-ludwig merge pls, this is really useful and further changes can be done afterwards |
web/vibe/web/web.d
Outdated
@@ -1020,8 +1029,10 @@ private void handleRequest(string M, alias overload, C, ERROR...)(HTTPServerRequ | |||
} else { | |||
res.writeBody(ret); | |||
} | |||
} else static if (is(RET : string)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const(char)[]
is sufficient here.
web/vibe/web/web.d
Outdated
} 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."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to add const(ubyte)[]
here, too (and change to const(char)[]
if adjusted).
Couldn't find a compelling argument against this, especially considering that |
Good idea. Done. |
Split-off from #1697