I'm trying to generate JS for my simple REST API like eg described here: doc . My example code:
import vibe.d;
import wbapi;
import std.array : appender;
import vibe.core.file;
void main()
{
// generate JS for access
auto test = appender!string;
auto settingsJS = new RestInterfaceSettings;
settingsJS.baseURL = URL("http://localhost/api/integration/");
generateRestJSClient!IfWhiteBlowerAPI(test, settingsJS);
}
and interface:
@path("/api/integration")
interface IfWhiteBlowerAPI
{
Json get();
string postDeaf(Json obj);
}
Everything is compiling without any problem but i can't find generated JS anywhere. Am i looking in wrong place - main tree of app project?
I get help on vibed IRC channel. There is appender which is "handling" generated JS data. After we generate it we need to save it to file manually, below working example:
import vibe.d;
import std.stdio;
import std.array : appender;
import vibe.core.file;
@path("/api/integration")
interface IfWhiteBlowerAPI
{
Json get();
string postDeaf(Json obj);
}
void main()
{
// generate JS for access
auto test = appender!string;
auto settingsJS = new RestInterfaceSettings;
settingsJS.baseURL = URL("http://localhost/api/integration/");
generateRestJSClient!IfWhiteBlowerAPI(test, settingsJS);
auto f = File("test.js", "w");
f.write(test.data);
f.close();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.