Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Middleware for Compression in HORSE

License

NotificationsYou must be signed in to change notification settings

HashLoad/horse-compression

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

horse-compression is an official middleware for compressing content in APIs developed with theHorse framework.
We created a channel on Telegram for questions and support:

⚙️ Installation

Installation is done using theboss install command:

boss install horse-compression

If you choose to install manually, simply add the following folders to your project, inProject > Options > Resource Compiler > Directories and Conditionals > Include file search path

../horse-compression/src

✔️ Compatibility

This middleware is compatible with projects developed in:

  • Delphi
  • Lazarus

☑️ Compression types

Currently, the middleware is prepared to compress the data using DEFLATE and GZIP.

TypeDelphiLazarus
DEFLATE   ✔️    ✔️
GZIP   ✔️    ❌

⚡️ Quickstart Delphi

uses  Horse,  Horse.Jhonson,  Horse.Compression,// It's necessary to use the unit  System.JSON;begin  THorse    .Use(Compression())// Must come before Jhonson middleware    .Use(Jhonson);// You can set compression threshold:// THorse.Use(Compression(1024));  THorse.Get('/ping',    procedure(Req: THorseRequest; Res: THorseResponse; Next: TProc)var      I: Integer;      LPong: TJSONArray;begin      LPong := TJSONArray.Create;for I :=0to1000do        LPong.Add(TJSONObject.Create(TJSONPair.Create('ping','pong')));      Res.Send(LPong);end);  THorse.Listen(9000);end;

⚡️ Quickstart Lazarus

{$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;procedureGetPing(Req: THorseRequest; Res: THorseResponse; Next: TNextProc);var  I: Integer;  LPong: TJSONArray;  LJson: TJSONObject;begin  LPong := TJSONArray.Create;for I :=0to1000dobegin    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

When using the middleware, the response size was approximately 67 times smaller. Data were collected using the project available within thesamples (delphi) folder. To default, responses less than or equal to 1024 bytes will not be compressed.

PropertyWithoutWith
Time(ms)108126
Size(bytes)15.770236

⚠️ License

horse-compression is free and open-source middleware licensed under theMIT License.

About

Middleware for Compression in HORSE

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors6

Languages


[8]ページ先頭

©2009-2025 Movatter.jp