Skip to content

Commit 9c35f74

Browse files
authored
[D] update libraries versions (the-benchmarker#7152)
* [D] update libraries versions For CGI and Serverino just bump the version. For Handy - update the code with new functionality of PathHandler which is a recommended way from web-site * [D] Handy fixes Added proper config for server and switch-off logging output.
1 parent c422589 commit 9c35f74

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

d/cgi/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
framework:
22
github: adamdruppe/arsd
3-
version: "11.2"
3+
version: "11.3"

d/cgi/dub.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "server",
33
"dependencies": {
4-
"arsd-official:cgi": "~>11.2.3"
4+
"arsd-official:cgi": "~>11.3.0"
55
},
66
"dflags-ldc": [
77
"-mcpu=native",

d/handy/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
framework:
22
github: andrewlalis/handy-httpd
3-
version: 7.13
3+
version: 7.16

d/handy/dub.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "server",
33
"dependencies": {
4-
"handy-httpd": "~>7.13.0"
4+
"handy-httpd": "~>7.16.1"
55
},
66
"dflags-ldc": [
77
"-mcpu=native",

d/handy/source/app.d

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import handy_httpd;
2-
import std.parallelism: totalCPUs;
3-
import std.algorithm: startsWith;
2+
import handy_httpd.handlers.path_handler;
43

54
void main() {
5+
import slf4d;
6+
import slf4d.default_provider;
7+
8+
auto provider = new shared DefaultProvider(true, Levels.ERROR);
9+
configureLoggingProvider(provider);
10+
611
ServerConfig cfg = ServerConfig.defaultValues();
7-
cfg.workerPoolSize = 2*totalCPUs;
812
cfg.hostname = "0.0.0.0";
913
cfg.port = 3000;
10-
new HttpServer((ref ctx) {
11-
if (ctx.request.url == "") {
12-
ctx.response.setStatus(HttpStatus.OK);
13-
ctx.response.writeBodyString("");
14-
} else if (ctx.request.url == "/user" && ctx.request.method == Method.POST) {
15-
ctx.response.setStatus(HttpStatus.OK);
16-
ctx.response.writeBodyString("");
17-
} else if (startsWith(ctx.request.url, "/user/") && ctx.request.method == Method.GET) {
18-
ctx.response.setStatus(HttpStatus.OK);
19-
ctx.response.writeBodyString(ctx.request.url[6..$]);
20-
}
21-
}, cfg).start();
14+
cfg.enableWebSockets = false;
15+
16+
auto pathHandler = new PathHandler()
17+
.addMapping(Method.GET, "/", (ref ctx) {ctx.response.okResponse();})
18+
.addMapping(Method.POST, "/user", (ref ctx) {ctx.response.okResponse();})
19+
.addMapping(Method.GET, "/user/:userId", (ref ctx) {ctx.response.okResponse(ctx.request.pathParams["userId"]);});
20+
21+
new HttpServer(pathHandler, cfg).start();
2222
}

d/serverino/dub.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "server",
33
"dependencies": {
4-
"serverino": "~>0.5.0"
4+
"serverino": "~>0.5.1"
55
},
66
"dflags-ldc": [
77
"-mcpu=native",

0 commit comments

Comments
 (0)