Vibe.d - 无法为 rest API 生成 JS 脚本



我正在尝试为我的简单 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。我是否找错了地方 - 应用程序项目的主树?

我在vibed IRC频道上得到帮助。有一个附加器正在"处理"生成的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();
}

最新更新