I am trying to implement a simple REST API that returns some binary data to a user (it could be BSON format or just the RAW binary data).
Say I define the following interface:
@getRootPathFromName
interface MyAPI
{
@path("getdata") @method(HTTPMethod.GET)
ubyte[] getData();
}
class MyImpl : MyAPI
{
override ubyte[] getData() {
ubyte[] the_data;
the_data ~= 1;
the_data ~= 2;
the_data ~= 3;
return the_data;
}
}
Running code like this returns the text '[1,2,3]' in JSON format. If I want to send the binary data (or perhaps a file - say .png or .jpg) how could I handle this.