Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciussanchez authored Dec 28, 2021
1 parent b018c42 commit 375b8a9
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Currently, the middleware is prepared to compress the data using DEFLATE and GZI
| DEFLATE |    ✔️ |     ✔️ |
| GZIP |    ✔️ |     |

## ⚡️ Quickstart
## ⚡️ Quickstart Delphi
```delphi
uses
Horse,
Expand Down Expand Up @@ -59,6 +59,50 @@ begin
end;
```

## ⚡️ Quickstart Lazarus
```delphi
{$MODE DELPHI}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Horse,
Horse.Jhonson,
Horse.Compression, // It's necessary to use the unit
fpjson,
SysUtils;
procedure GetPing(Req: THorseRequest; Res: THorseResponse; Next: TNextProc);
var
I: Integer;
LPong: TJSONArray;
LJson: TJSONObject;
begin
LPong := TJSONArray.Create;
for I := 0 to 1000 do
begin
LJson := TJSONObject.Create;
LJson.Add('ping', 'pong');
LPong.Add(LJson);
end;
Res.Send<TJSONArray>(LPong);
end;
begin
THorse
.Use(Compression()) // Must come before Jhonson middleware
.Use(Jhonson);
// You can set compression threshold:
// THorse.Use(Compression(1024));
THorse.Get('/ping', GetPing);
THorse.Listen(9000);
end.
```

## 🚀 Statistics

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.
Expand Down

0 comments on commit 375b8a9

Please sign in to comment.