{"id":19133604,"url":"https://github.com/hashload/horse-compression","last_synced_at":"2025-11-12T20:03:30.264Z","repository":{"id":50889990,"uuid":"204811559","full_name":"HashLoad/horse-compression","owner":"HashLoad","description":"Middleware for Compression in HORSE","archived":false,"fork":false,"pushed_at":"2023-09-19T13:10:03.000Z","size":57,"stargazers_count":32,"open_issues_count":1,"forks_count":14,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-04-14T00:32:23.587Z","etag":null,"topics":["compression","horse","middleware"],"latest_commit_sha":null,"homepage":"https://horse.hashload.com","language":"Pascal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HashLoad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-08-28T00:05:05.000Z","updated_at":"2023-11-30T00:36:37.000Z","dependencies_parsed_at":"2023-09-25T23:32:15.413Z","dependency_job_id":null,"html_url":"https://github.com/HashLoad/horse-compression","commit_stats":{"total_commits":42,"total_committers":7,"mean_commits":6.0,"dds":"0.23809523809523814","last_synced_commit":"250fa0f4394d663345c1c5b222f3b22d245b5f2e"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashLoad%2Fhorse-compression","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashLoad%2Fhorse-compression/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashLoad%2Fhorse-compression/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashLoad%2Fhorse-compression/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HashLoad","download_url":"https://codeload.github.com/HashLoad/horse-compression/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240214566,"owners_count":19766263,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compression","horse","middleware"],"created_at":"2024-11-09T06:23:04.204Z","updated_at":"2025-11-12T20:03:30.245Z","avatar_url":"https://github.com/HashLoad.png","language":"Pascal","readme":"# horse-compression\n\u003cb\u003ehorse-compression\u003c/b\u003e is an official middleware for compressing content in APIs developed with the \u003ca href=\"https://github.com/HashLoad/horse\"\u003eHorse\u003c/a\u003e framework.\n\u003cbr\u003eWe created a channel on Telegram for questions and support:\u003cbr\u003e\u003cbr\u003e\n\u003ca href=\"https://t.me/hashload\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/telegram-join%20channel-7289DA?style=flat-square\"\u003e\n\u003c/a\u003e\n\n## ⚙️ Installation\nInstallation is done using the [`boss install`](https://github.com/HashLoad/boss) command:\n``` sh\nboss install horse-compression\n```\nIf you choose to install manually, simply add the following folders to your project, in *Project \u003e Options \u003e Resource Compiler \u003e Directories and Conditionals \u003e Include file search path*\n```\n../horse-compression/src\n```\n\n## ✔️ Compatibility\nThis middleware is compatible with projects developed in:\n- [X] Delphi\n- [X] Lazarus\n\n## ☑️ Compression types\nCurrently, the middleware is prepared to compress the data using DEFLATE and GZIP.\n| Type | Delphi | Lazarus |\n| -------- | -------------------- | --------------------------- |\n|  DEFLATE | \u0026nbsp;\u0026nbsp;\u0026nbsp;✔️ | \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;✔️ |\n|  GZIP    | \u0026nbsp;\u0026nbsp;\u0026nbsp;✔️ | \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;❌ |\n\n## ⚡️ Quickstart Delphi\n```delphi\nuses\n  Horse,\n  Horse.Jhonson,\n  Horse.Compression, // It's necessary to use the unit\n  System.JSON;\n\nbegin\n  THorse\n    .Use(Compression()) // Must come before Jhonson middleware\n    .Use(Jhonson);\n\n  // You can set compression threshold:\n  // THorse.Use(Compression(1024));\n\n  THorse.Get('/ping',\n    procedure(Req: THorseRequest; Res: THorseResponse; Next: TProc)\n    var\n      I: Integer;\n      LPong: TJSONArray;\n    begin\n      LPong := TJSONArray.Create;\n      for I := 0 to 1000 do\n        LPong.Add(TJSONObject.Create(TJSONPair.Create('ping', 'pong')));\n      Res.Send(LPong);\n    end);\n\n  THorse.Listen(9000);\nend;\n```\n\n## ⚡️ Quickstart Lazarus\n```delphi\n{$MODE DELPHI}{$H+}\n\nuses\n  {$IFDEF UNIX}{$IFDEF UseCThreads}\n  cthreads,\n  {$ENDIF}{$ENDIF}\n  Horse,\n  Horse.Jhonson,\n  Horse.Compression, // It's necessary to use the unit\n  fpjson,\n  SysUtils;\n\nprocedure GetPing(Req: THorseRequest; Res: THorseResponse; Next: TNextProc);\nvar\n  I: Integer;\n  LPong: TJSONArray;\n  LJson: TJSONObject;\nbegin\n  LPong := TJSONArray.Create;\n  for I := 0 to 1000 do\n  begin\n    LJson := TJSONObject.Create;\n    LJson.Add('ping', 'pong');\n    LPong.Add(LJson);\n  end;\n  Res.Send\u003cTJSONArray\u003e(LPong);\nend;\n\nbegin\n  THorse\n    .Use(Compression()) // Must come before Jhonson middleware\n    .Use(Jhonson);\n\n  // You can set compression threshold:\n  // THorse.Use(Compression(1024));\n\n  THorse.Get('/ping', GetPing);\n\n  THorse.Listen(9000);\nend.\n```\n\n## 🚀 Statistics \n\nWhen using the middleware, the response size was approximately 67 times 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.\n\nProperty    | Without | With\n:---------: | ------: | ------:\nTime(ms)    |     108 | 126\nSize(bytes) |  15.770 | 236\n\n## ⚠️ License\n`horse-compression` is free and open-source middleware licensed under the [MIT License](https://github.com/HashLoad/horse-compression/blob/master/LICENSE). \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhashload%2Fhorse-compression","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhashload%2Fhorse-compression","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhashload%2Fhorse-compression/lists"}