-
Notifications
You must be signed in to change notification settings - Fork 277
Description
https://vibed.org/api/vibe.web.rest/ says:
Custom serialization can be achieved by defining JSON or string parameters/return values together with the appropriate @bodyParam annotations.
and:
The most basic interface that can be defined is as follows:
@path("/api/") interface APIRoot { string get(); }This defines an API that has a single endpoint, 'GET /api/'. So if the server is found at http://api.example.com, performing a GET request to http://api.example.com/api/ will call the get() method and send its return value verbatim as the response body.
(ehpmasis added)
However, the following endpoint:
@path("/test")
interface ITestController {
string get();
}
final class TestController : ITestController {
override string get() {
return "hello";
}
}actually returns "hello", and not hello, meaning that the string was serialized to JSON as usual.
I also couldn't find any trace of this feature in the code. The return type is passed to ResultSerializersT here, falling back by default to DefaultSerializerT, which only contains the JSON serializer.
I was going to file an issue to suggest that const(ubyte)[] is added to the list of types returned verbatim, but it doesn't look like even strings work here. (However, looks like for now this can be achieved by returning a Vibe input stream object.)