Add HTTP server routes
This commit is contained in:
parent
cd2356ae2a
commit
ad25f4df24
31
source/app.d
31
source/app.d
|
@ -9,13 +9,6 @@ import vibe.d;
|
||||||
import vibe.data.json;
|
import vibe.data.json;
|
||||||
import vibe.textfilter.urlencode;
|
import vibe.textfilter.urlencode;
|
||||||
|
|
||||||
void helloWorld(HTTPServerRequest req,
|
|
||||||
HTTPServerResponse res)
|
|
||||||
{
|
|
||||||
res.writeBody("Hello");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ApiRequest
|
class ApiRequest
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -345,15 +338,6 @@ class ApiClient
|
||||||
|
|
||||||
shared static this()
|
shared static this()
|
||||||
{
|
{
|
||||||
auto router = new URLRouter;
|
|
||||||
router.get("/hello", &helloWorld);
|
|
||||||
|
|
||||||
auto settings = new HTTPServerSettings;
|
|
||||||
settings.sessionStore = new MemorySessionStore;
|
|
||||||
settings.port = 8080;
|
|
||||||
settings.bindAddresses = ["::1", "127.0.0.1"];
|
|
||||||
|
|
||||||
listenHTTP(settings, router);
|
|
||||||
|
|
||||||
auto apiClient = new ApiClient("nl_BE");
|
auto apiClient = new ApiClient("nl_BE");
|
||||||
apiClient.connect();
|
apiClient.connect();
|
||||||
|
@ -363,9 +347,14 @@ shared static this()
|
||||||
auto password = fromStringz(getpass("Password: ")).idup;
|
auto password = fromStringz(getpass("Password: ")).idup;
|
||||||
apiClient.login2(otp, password);
|
apiClient.login2(otp, password);
|
||||||
|
|
||||||
writeln("Account funds: " ~ apiClient.getAccountAvailable());
|
auto router = new URLRouter;
|
||||||
writeln("Card funds: " ~ apiClient.getCardAvailable());
|
router.get("/account/available", delegate(HTTPServerRequest, HTTPServerResponse response) { response.writeBody(apiClient.getAccountAvailable()); });
|
||||||
writeln("Account funds: " ~ apiClient.getAccountAvailable());
|
router.get("/card/available", delegate(HTTPServerRequest, HTTPServerResponse response) { response.writeBody(apiClient.getCardAvailable()); });
|
||||||
writeln("Card funds: " ~ apiClient.getCardAvailable());
|
|
||||||
writeln("Account funds: " ~ apiClient.getAccountAvailable());
|
auto settings = new HTTPServerSettings;
|
||||||
|
settings.sessionStore = new MemorySessionStore;
|
||||||
|
settings.port = 8080;
|
||||||
|
settings.bindAddresses = ["::1", "127.0.0.1"];
|
||||||
|
|
||||||
|
listenHTTP(settings, router);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue