vibe.d beta banner
get vibe.d
0.10.1

Asynchronous I/O that doesn’t get in your way, written in D

Function generateRestJSClient

Generates JavaScript code to access a REST interface from the browser.

void generateRestJSClient(I, R) (
  ref R output,
  RestInterfaceSettings settings = null
)
if (is(I == interface) && isOutputRange!(R, char));

Example

Writes a JavaScript REST client to a local .js file.

import vibe.core.file;

interface MyAPI {
	void getFoo();
	void postBar(string param);
}

void generateJSClientImpl()
{
	import std.array : appender;

	auto app = appender!string;
	auto settings = new RestInterfaceSettings;
	settings.baseURL = URL("http://localhost/");
	generateRestJSClient!MyAPI(app, settings);
}

generateJSClientImpl();
Authors

Sönke Ludwig, Михаил Страшун, Mathias 'Geod24' Lang

Copyright

© 2012-2018 Sönke Ludwig

License

Subject to the terms of the MIT license, as written in the included LICENSE.txt file.