我正在尝试为我的简单REST API生成JS,例如:doc。我的示例代码:
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);
}和接口:
@path("/api/integration")
interface IfWhiteBlowerAPI
{
Json get();
string postDeaf(Json obj);
}一切都在编译,没有任何问题,但是我在任何地方都找不到生成的JS。我是不是看错了地方-- app项目的主树?
发布于 2017-08-24 05:10:39
我在vibed IRC频道上得到了帮助。有一个appender,它“处理”生成的JS数据。生成后,我们需要手动将其保存到文件中,如以下工作示例所示:
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();
}https://stackoverflow.com/questions/45845705
复制相似问题