Skip to content

HashLoad/horse

Repository files navigation

Horse


Horse is an Express-inspired web framework for Delphi and Lazarus.
Designed to ease things up for fast development in a minimalist way and with high performance.


Read this in English or Português (BR).

⚙️ Installation

Installation is done using the boss install command:

boss install horse

(Optional) Install the Horse Wizard for IDE integration.

⚡️ Quickstart Delphi

uses Horse;

begin
  THorse.Get('/ping',
    procedure(Req: THorseRequest; Res: THorseResponse)
    begin
      Res.Send('pong');
    end);

  THorse.Listen(9000);
end.

⚡️ Quickstart Lazarus

{$MODE DELPHI}{$H+}

uses Horse;

procedure GetPing(Req: THorseRequest; Res: THorseResponse);
begin
  Res.Send('Pong');
end;

begin
  THorse.Get('/ping', GetPing);
  THorse.Listen(9000);
end.

📖 Documentation

The full guide lives in doc/ — a small wiki that complements the quick reference below:

Topic Read
First server, install paths, Delphi/Lazarus setup Getting Started
Defining routes, route params, route groups, query strings Routing
THorseRequest / THorseResponse — body, headers, cookies, sessions, status, streaming Request & Response
Using middleware, registration order, the Next proc Middleware
Writing & publishing your own middleware — skeleton, thread safety, Provider neutrality, Boss packaging Writing a Middleware
Choosing a transport provider — Indy (default), CrossSocket, Apache, ISAPI, CGI, daemons Providers
Deploy as Console / VCL / Daemon / Windows Service / LCL / HTTPApplication — one-page recipe Deployment Cheatsheet
Full middleware catalogue with extended descriptions Middleware Ecosystem
Supported Delphi / FPC versions and platforms Compiler Support

🔌 Providers (transport layer)

A provider is the HTTP transport that owns the socket and hands requests to your route handlers. The same handler code runs under any provider — you select one at compile time via a Conditional Define. The default Provider depends on the compiler: Indy on Delphi (for Console / VCL / Daemon), fphttpserver on FPC (for Daemon / HTTPApplication / LCL). The optional CrossSocket Provider replaces both with async IOCP / epoll / kqueue I/O.

Provider Compiler define Delphi Lazarus
Indy (Delphi default for self-hosted) (none)    ✔️     n/a
fphttpserver (FPC default for self-hosted) (none)    n/a     ✔️
🆕 horse-provider-crosssocket HORSE_CROSSSOCKET    ✔️     ✔️
(planned) horse-provider-mormot HORSE_MORMOT    —     —

Note — Apache / ISAPI / CGI / FastCGI Application types (below) do not use any of these Providers. The host process (Apache, IIS, the web server) owns the socket; Horse runs in-process. See Providers & Application types for the full model.

🎯 Application types

How the binary is packaged and started. Self-hosted types run under the chosen Provider above; host-managed types delegate the socket to the web server, which then becomes the transport.

Application type Compiler define Delphi Lazarus
Self-hosted (uses the selected Provider)
Console (default) (none)    ✔️     ✔️
VCL HORSE_VCL    ✔️     ❌
Daemon (Windows service) HORSE_DAEMON    ✔️     ✔️
LCL (Lazarus GUI) HORSE_LCL    ❌     ✔️
HTTPApplication (FPC) (FPC default)    ❌     ✔️
Host-managed (the web server owns the socket; Provider above is unused)
Apache module HORSE_APACHE    ✔️     ✔️
ISAPI (IIS) HORSE_ISAPI    ✔️     ❌
CGI HORSE_CGI    ✔️     ✔️
FastCGI HORSE_FCGI    ✔️     ✔️

See Providers for the full compatibility matrix and how to combine Provider × Application type.

🧬 Official Middlewares

For a more maintainable middleware ecosystem, we've put official middlewares into separate repositories:

Middleware Delphi Lazarus
horse/json    ✔️     ✔️
horse/basic-auth    ✔️     ✔️
horse/cors    ✔️     ✔️
horse/stream    ✔️     ✔️
horse/jwt    ✔️     ✔️
horse/exception    ✔️     ✔️
horse/logger    ✔️     ✔️
horse/compression    ✔️     ✔️

🌱 Third Party Middlewares

This is a list of middlewares that are created by the Horse community, please create a PR if you want to see yours!

Middleware Delphi Lazarus
bittencourtthulio/etag    ✔️     ✔️
bittencourtthulio/paginate    ✔️     ✔️
bittencourtthulio/cachecontrol    ✔️     ❌
gabrielbaltazar/gbswagger    ✔️     ❌
willhubner/socketIO    ✔️     ❌
dliocode/ratelimit    ✔️     ❌
dliocode/slowdown    ✔️     ❌
giorgiobazzo/upload    ✔️     ❌
dliocode/query    ✔️     ❌
CarlosHe/healthcheck    ✔️     ❌
CarlosHe/staticfiles    ✔️     ❌
CachopaWeb/horse-server-static    ✔️     ✔️
arvanus/horse-exception-logger    ✔️     ✔️
claudneysessa/Horse-CSResponsePagination    ✔️     ❌
claudneysessa/Horse-XSuperObjects    ✔️     ❌
andre-djsystem/horse-bearer-auth    ✔️     ✔️
andre-djsystem/horse-manipulate-request    ✔️     ✔️
andre-djsystem/horse-manipulate-response    ✔️     ✔️
antoniojmsjr/Horse-IPGeoLocation    ✔️     ❌
antoniojmsjr/Horse-XMLDoc    ✔️     ❌
isaquepinheiro/horse-jsonbr    ✔️     ❌
IagooCesaar/Horse-JsonInterceptor    ✔️     ❌
dliocode/horse-datalogger    ✔️     ❌
marcobreveglieri/horse-prometheus-metrics    ✔️     ❌
weslleycapelari/horse-documentation    ✔️     ❌
weslleycapelari/horse-validator    ✔️     ❌

Delphi Versions

Horse works with Delphi 13 Florence, Delphi 12 Athens, Delphi 11 Alexandria, Delphi 10.4 Sydney, Delphi 10.3 Rio, Delphi 10.2 Tokyo, Delphi 10.1 Berlin, Delphi 10 Seattle, Delphi XE8 and Delphi XE7.

For the full platform matrix per provider, see Compiler Support.

🤝 Contributing

See CONTRIBUTING.md for how to report bugs, suggest features, and submit code or documentation changes. Bilingual EN / PT-BR docs are kept in sync — when editing one language, edit the other in the same PR.

💻 Code Contributors

⚠️ License

Horse is free and open-source software licensed under the MIT License.

📐 Tests

tests Console Coverage VCL Coverage

Sponsor this project

Packages

 
 
 

Contributors