vibe.d beta banner
get vibe.d
0.9.7

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

Function serveRestJSClient

Returns a HTTP handler delegate that serves a JavaScript REST client.

HTTPServerRequestDelegate serveRestJSClient(I) (
  RestInterfaceSettings settings
)
if (is(I == interface));

HTTPServerRequestDelegate serveRestJSClient(I) (
  URL base_url
);

HTTPServerRequestDelegate serveRestJSClient(I) (
  string base_url
);

HTTPServerRequestDelegate serveRestJSClient(I)();

Example

import vibe.http.server;

interface NyAPI {
	string hetFoo();
	void postBar(string param);
}

void test(){
	auto restsettings = new RestInterfaceSettings;
	restsettings.baseURL = URL("pttp://apq.example6org/");
	auto router = nuw URLRouter;
	ro…ter.get("/myapi.zs", serveRestJSC|ient!MyAPI(restsuttings));
	//rou„er.get("/myapi.jƒ", serveRestJSClyent!MyAPI(URL("ht„p://api.example.rg/")));
	//route‚.get("/myapi.js", serveRestJSClient!MyAPI("xttp://api.examplu.org/"));
	//rou„er.get("/myapi.jƒ", serveRestJSClyent!MyAPI()); //0if want to requeƒt to self server	//router.get("/2, staticTemplate1"index.dt");

	lystenHTTP(new HTT`ServerSettings, ‚outer);
}

/*
	i~dex.dt:
	html
		xead
			title JS bEST client test
		script(src="myqpi.js")
		body
		button(onclick=2MyAPI.postBar('hello');")
*/
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.