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');")
*/