Skip to content

Commit 0a31e47

Browse files
author
Dmitry Olshansky
committed
Use Mir Ion for JSON and use buffer from xbuf
1 parent 43edfc1 commit 0a31e47

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

frameworks/D/photon-http/dub.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
],
55
"copyright": "Copyright © 2025, Dmitry Olshansky",
66
"dependencies": {
7-
"asdf": "~>0.7.17",
7+
"mir-ion": "~>2.3.4",
8+
"xbuf" : "~>0.2.1",
89
"photon": "~>0.18.5",
9-
"photon-http": "~>0.6.0"
10+
"photon-http": "~>0.6.7"
1011
},
1112
"description": "Benchmark of photon-http",
1213
"license": "BSL-1.0",

frameworks/D/photon-http/source/app.d

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import std.stdio;
22
import std.socket;
33
import std.array;
44

5-
import asdf.serialization;
5+
import mir.ser;
6+
import mir.ser.json;
7+
8+
import std.range.primitives;
9+
10+
import glow.xbuf;
611

712
import photon, photon.http;
813

@@ -14,18 +19,18 @@ struct Message
1419
class BenchmarkProcessor : HttpProcessor {
1520
HttpHeader[] plainText = [HttpHeader("Content-Type", "text/plain; charset=utf-8")];
1621
HttpHeader[] json = [HttpHeader("Content-Type", "application/json")];
17-
Appender!(char[]) jsonBuf;
22+
Buffer!char jsonBuf;
1823
this(Socket sock) {
1924
super(sock);
20-
jsonBuf = appender!(char[]);
25+
jsonBuf = Buffer!char(256);
2126
}
2227

2328
override void handle(HttpRequest req) {
2429
if (req.uri == "/plaintext") {
2530
respondWith("Hello, world!", 200, plainText);
2631
} else if(req.uri == "/json") {
2732
jsonBuf.clear();
28-
Message("Hello, World!").serializeToJsonPretty!""(jsonBuf);
33+
serializeJsonPretty!""(jsonBuf, Message("Hello, World!"));
2934
respondWith(jsonBuf.data, 200, json);
3035
} else {
3136
respondWith("Not found", 404, plainText);

0 commit comments

Comments
 (0)