Skip to content

Commit 375b8a9

Browse files
Update README.md
1 parent b018c42 commit 375b8a9

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

README.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Currently, the middleware is prepared to compress the data using DEFLATE and GZI
2727
| DEFLATE |    ✔️ |     ✔️ |
2828
| GZIP |    ✔️ |     |
2929

30-
## ⚡️ Quickstart
30+
## ⚡️ Quickstart Delphi
3131
```delphi
3232
uses
3333
Horse,
@@ -59,6 +59,50 @@ begin
5959
end;
6060
```
6161

62+
## ⚡️ Quickstart Lazarus
63+
```delphi
64+
{$MODE DELPHI}{$H+}
65+
66+
uses
67+
{$IFDEF UNIX}{$IFDEF UseCThreads}
68+
cthreads,
69+
{$ENDIF}{$ENDIF}
70+
Horse,
71+
Horse.Jhonson,
72+
Horse.Compression, // It's necessary to use the unit
73+
fpjson,
74+
SysUtils;
75+
76+
procedure GetPing(Req: THorseRequest; Res: THorseResponse; Next: TNextProc);
77+
var
78+
I: Integer;
79+
LPong: TJSONArray;
80+
LJson: TJSONObject;
81+
begin
82+
LPong := TJSONArray.Create;
83+
for I := 0 to 1000 do
84+
begin
85+
LJson := TJSONObject.Create;
86+
LJson.Add('ping', 'pong');
87+
LPong.Add(LJson);
88+
end;
89+
Res.Send<TJSONArray>(LPong);
90+
end;
91+
92+
begin
93+
THorse
94+
.Use(Compression()) // Must come before Jhonson middleware
95+
.Use(Jhonson);
96+
97+
// You can set compression threshold:
98+
// THorse.Use(Compression(1024));
99+
100+
THorse.Get('/ping', GetPing);
101+
102+
THorse.Listen(9000);
103+
end.
104+
```
105+
62106
## 🚀 Statistics
63107

64108
Using middleware, the response was approximately 67 turn smaller. Data were collected using the project available within the [samples (delphi)](https://github.com/HashLoad/horse-compression/tree/master/samples/delphi) folder. To default, responses less than or equal to 1024 bytes will not be compressed.

0 commit comments

Comments
 (0)