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.textfilter.urlencode;
|
||||
|
||||
void helloWorld(HTTPServerRequest req,
|
||||
HTTPServerResponse res)
|
||||
{
|
||||
res.writeBody("Hello");
|
||||
}
|
||||
|
||||
|
||||
class ApiRequest
|
||||
{
|
||||
}
|
||||
|
@ -345,15 +338,6 @@ class ApiClient
|
|||
|
||||
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");
|
||||
apiClient.connect();
|
||||
|
@ -363,9 +347,14 @@ shared static this()
|
|||
auto password = fromStringz(getpass("Password: ")).idup;
|
||||
apiClient.login2(otp, password);
|
||||
|
||||
writeln("Account funds: " ~ apiClient.getAccountAvailable());
|
||||
writeln("Card funds: " ~ apiClient.getCardAvailable());
|
||||
writeln("Account funds: " ~ apiClient.getAccountAvailable());
|
||||
writeln("Card funds: " ~ apiClient.getCardAvailable());
|
||||
writeln("Account funds: " ~ apiClient.getAccountAvailable());
|
||||
auto router = new URLRouter;
|
||||
router.get("/account/available", delegate(HTTPServerRequest, HTTPServerResponse response) { response.writeBody(apiClient.getAccountAvailable()); });
|
||||
router.get("/card/available", delegate(HTTPServerRequest, HTTPServerResponse response) { response.writeBody(apiClient.getCardAvailable()); });
|
||||
|
||||
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