Skip to content

Commit

Permalink
Fix style on the examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Geod24 committed Jun 13, 2015
1 parent ccb359d commit 2159733
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 58 deletions.
2 changes: 1 addition & 1 deletion examples/app_skeleton/source/app.d
Expand Up @@ -18,7 +18,7 @@ shared static this()
router.get("/", &showHome);
router.get("/about", staticTemplate!"about.dt");
router.get("*", serveStaticFiles("public"));

auto settings = new HTTPServerSettings;
settings.port = 8080;
settings.errorPageHandler = toDelegate(&showError);
Expand Down
2 changes: 1 addition & 1 deletion examples/app_skeleton/source/index.d
Expand Up @@ -10,4 +10,4 @@ void showHome(HTTPServerRequest req, HTTPServerResponse res)
//res.renderCompat!("home.dt",
// HTTPServerRequest, "req",
// string, "username")(req, username);
}
}
2 changes: 1 addition & 1 deletion examples/bench-http-request/source/app.d
Expand Up @@ -46,7 +46,7 @@ void distTask()
static shared int s_threadCount = 0;
static shared int s_token = 0;
int id = atomicOp!"+="(s_threadCount, 1) - 1;

while (true) {
while (atomicLoad(s_token) != id && g_concurrency > 0) {}
if (g_concurrency == 0) break;
Expand Down
4 changes: 2 additions & 2 deletions examples/diet/source/app.d
Expand Up @@ -6,7 +6,7 @@ void handleRequest(scope HTTPServerRequest req, scope HTTPServerResponse res)
string local_var = "Hello, World!";
bool is_admin = false;
res.headers["Content-Type"] = "text/html";

res.render!("diet.dt", req, local_var, is_admin);
}

Expand All @@ -15,6 +15,6 @@ shared static this()
auto settings = new HTTPServerSettings;
settings.port = 8080;
settings.bindAddresses = ["::1", "127.0.0.1"];

listenHTTP(settings, &handleRequest);
}
2 changes: 1 addition & 1 deletion examples/http_info/source/app.d
Expand Up @@ -7,6 +7,6 @@ shared static this()
settings.sessionStore = new MemorySessionStore();
settings.port = 8080;
settings.bindAddresses = ["::1", "127.0.0.1"];

listenHTTP(settings, staticTemplate!("info.dt"));
}
2 changes: 1 addition & 1 deletion examples/http_reverse_proxy/source/app.d
Expand Up @@ -10,4 +10,4 @@ shared static this()
settings.bindAddresses = ["::1", "127.0.0.1"];

listenHTTPReverseProxy(settings, "www.heise.de", 80);
}
}
4 changes: 2 additions & 2 deletions examples/http_static_server/source/app.d
Expand Up @@ -13,13 +13,13 @@ shared static this()
auto settings = new HTTPServerSettings;
settings.port = 8080;
settings.bindAddresses = ["::1", "127.0.0.1"];

auto router = new URLRouter;
router.get("/", &handleRequest);
auto fileServerSettings = new HTTPFileServerSettings;
fileServerSettings.encodingFileExtension = ["gzip" : ".gz"];
router.get("/gzip/*", serveStaticFiles("./public/", fileServerSettings));
router.get("*", serveStaticFiles("./public/",));

listenHTTP(settings, router);
}
2 changes: 1 addition & 1 deletion examples/https_server/source/app.d
Expand Up @@ -15,6 +15,6 @@ shared static this()
settings.sslContext = createSSLContext(SSLContextKind.server);
settings.sslContext.useCertificateChainFile("server.crt");
settings.sslContext.usePrivateKeyFile("server.key");

listenHTTP(settings, &handleRequest);
}
50 changes: 25 additions & 25 deletions examples/json/source/app.d
@@ -1,25 +1,25 @@
import vibe.data.json;

import std.stdio;
import std.bigint;

void main()
{
Json a = 1;
Json b = 2;
writefln("%s %s", a.type, b.type);
auto c = a + b;
c = c * 2;
writefln("%d", cast(long)c);
Json[string] obj;
obj["item1"] = a;
obj["item2"] = "Object";
Json parent = obj;
parent.remove("item1");
foreach (i; obj) writeln(i);

auto obj2 = parseJsonString(`{"serial":17559991181826658461}`);
writeln("serial: ", obj2["serial"]);
assert(obj2["serial"] == BigInt(17559991181826658461UL));
}
import vibe.data.json;

import std.stdio;
import std.bigint;

void main()
{
Json a = 1;
Json b = 2;
writefln("%s %s", a.type, b.type);
auto c = a + b;
c = c * 2;
writefln("%d", cast(long)c);

Json[string] obj;
obj["item1"] = a;
obj["item2"] = "Object";
Json parent = obj;
parent.remove("item1");
foreach (i; obj) writeln(i);

auto obj2 = parseJsonString(`{"serial":17559991181826658461}`);
writeln("serial: ", obj2["serial"]);
assert(obj2["serial"] == BigInt(17559991181826658461UL));
}
8 changes: 4 additions & 4 deletions examples/message/source/app.d
Expand Up @@ -32,23 +32,23 @@ shared static this()
sleep(1.seconds());
logInfo("send Hello World");
t1.send("Hello, World!");

sleep(1.seconds());
logInfo("send int 1");
t1.send(1);

sleep(1.seconds());
logInfo("send double 1.2");
t1.send(1.2);

sleep(1.seconds());
logInfo("send int 2");
t1.send(2);

sleep(1.seconds());
logInfo("send 3xint 1 2 3");
t1.send(1, 2, 3);

sleep(1.seconds());
logInfo("send string Bye bye");
t1.send("Bye bye");
Expand Down
22 changes: 11 additions & 11 deletions examples/rest/source/app.d
Expand Up @@ -119,8 +119,8 @@ class Example2 : Example2API
import std.algorithm;
// Some sweet functional D
return reduce!(
(a, b) => Aggregate(a.name ~ b.name, a.count + b.count, Aggregate.Type.Type3)
)(Aggregate.init, input);
(a, b) => Aggregate(a.name ~ b.name, a.count + b.count, Aggregate.Type.Type3)
)(Aggregate.init, input);
}
}

Expand Down Expand Up @@ -475,7 +475,7 @@ shared static this()
auto api = new RestInterfaceClient!Example6API("http://127.0.0.1:8080");
// First we make sure parameters are transmitted via headers.
auto res = requestHTTP("http://127.0.0.1:8080/example6_api/response",
(scope r) {
(scope r) {
r.method = HTTPMethod.GET;
r.headers["Authorization"] = "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==";
});
Expand All @@ -494,7 +494,7 @@ shared static this()

// First we make sure parameters are transmitted via query.
auto res = requestHTTP("http://127.0.0.1:8080/example6_api/answer?qparam=Life_universe_and_the_rest",
(scope r) { r.method = HTTPMethod.POST; });
(scope r) { r.method = HTTPMethod.POST; });
assert(res.statusCode == 200);
assert(res.bodyReader.readAllUTF8() == `"True"`);
// Then we check that both can communicate together.
Expand All @@ -513,13 +513,13 @@ shared static this()
auto api = new RestInterfaceClient!Example6API("http://127.0.0.1:8080");
// First we make sure parameters are transmitted via query.
auto res = requestHTTP("http://127.0.0.1:8080/example6_api/concat",
(scope r) {
import vibe.data.json;
r.method = HTTPMethod.GET;
Json obj = Json.emptyObject;
obj["parameter"] = serializeToJson(Example6API.FooType(42, "fortySomething", 51.42));
r.writeJsonBody(obj);
});
(scope r) {
import vibe.data.json;
r.method = HTTPMethod.GET;
Json obj = Json.emptyObject;
obj["parameter"] = serializeToJson(Example6API.FooType(42, "fortySomething", 51.42));
r.writeJsonBody(obj);
});

assert(res.statusCode == 200);
assert(res.bodyReader.readAllUTF8() == `"`~expected~`"`);
Expand Down
4 changes: 2 additions & 2 deletions examples/sendmail/source/app.d
Expand Up @@ -15,8 +15,8 @@ void main()
mail.headers["To"] = "<recipient@domain.com>";
mail.headers["Subject"] = "Testmail";
mail.bodyText = "Hello, World!";

logInfo("Sending mail...");
sendMail(settings, mail);
logInfo("done.");
}
}
2 changes: 1 addition & 1 deletion examples/serialization/source/app.d
Expand Up @@ -5,7 +5,7 @@ import vibe.data.bson;


void main()
{
{
// set up some data to serialize
Data data;
data.number = 13;
Expand Down
2 changes: 1 addition & 1 deletion examples/udp/source/app.d
Expand Up @@ -15,7 +15,7 @@ shared static this()
logInfo("Got packet: %s", cast(string)pack);
}
});

runTask({
auto udp_sender = listenUDP(0);
udp_sender.connect("127.0.0.1", 1234);
Expand Down
6 changes: 3 additions & 3 deletions examples/web_ajax/source/app.d
Expand Up @@ -91,7 +91,7 @@ class App {

// the methods of DataProvider will be available at /data_provider/*
@property DataProvider dataProvider() { return m_provider; }

// GET /
void get()
{
Expand All @@ -116,14 +116,14 @@ class App {
void postAddUser(string name, string surname, string address)
{
dataProvider.postAddUser(name, surname, address);
redirect("/");
redirect("/");
}

// POST /add_user_structured
void postAddUserStructured(string name, string surname, Address address)
{
dataProvider.postAddUserStructured(name, surname, address);
redirect("/");
redirect("/");
}

// static methods are ignored.
Expand Down
2 changes: 1 addition & 1 deletion examples/websocket/source/app.d
Expand Up @@ -34,4 +34,4 @@ void handleWebSocketConnection(scope WebSocket socket)
socket.send(counter.to!string);
}
logInfo("Client disconnected.");
}
}

0 comments on commit 2159733

Please sign in to comment.