According to the documentation for the @after
UDA, we have the following:
http://vibed.org/api/vibe.web.rest/after
Writing to the response body from within the specified handler function causes any further processing of the request to be skipped, including any other @after annotations and writing the result value.
I intend to use this feature in order to write more customizable data conversions than just JSON as per the registerRestInterface
. Instead, I am registering my service via resisterWebInterface
and using logic in @after
handlers to run conversion functions to convert between D types and Media Types.
However, after writing to the response in my @after
handler using HTTPServerResponse.writeBody()
, I am finding that the code in web.d
still continues to attempt to write to the body in vibe.web.web.handleRequest
after running all @after
handlers with evaluateOutputModifiers()
.
} else {
auto ret = __traits(getMember, instance, M)(params);
ret = evaluateOutputModifiers!overload(ret, req, res);
static if (is(RET : Json)) {
res.writeJsonBody(ret);
} else static if (is(RET : InputStream) || is(RET : const ubyte[])) {
enum type = findFirstUDA!(ContentTypeAttribute, overload);
static if (type.found) {
res.writeBody(ret, type.value);
} else {
res.writeBody(ret);
}
} else static if (is(RET : const(char)[])) {
res.writeBody(ret);
} else {
static assert(is(RET == void), M~": Only `InputStream`, `const(ubyte[])`, `Json`, `const(char)[]` and `void` are supported as return types for route methods.");
}
How do I stop further writes to the body after writing data via an @after
handler for a class that was loaded using vibe.web.web.registerWebInterface
?