Horse Framework
Skill53 starsChanged 8 months agoMITView on GitHub
Patterns for developing REST APIs with Horse framework in Delphi
1 other project uses a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- delphicleancode/lazarus-spec-kitedited, first seen Apr 5, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- delphicleancode/lazarus-spec-kit★ 2165% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository35 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/acbr-patterns.mdCursor rule
- .cursor/rules/delphi-conventions.mdCursor rule
- .cursor/rules/design-patterns.mdCursor rule
- .cursor/rules/dext-patterns.mdCursor rule
- .cursor/rules/dmvc-patterns.mdCursor rule
- .cursor/rules/firebird-patterns.mdCursor rule
- .cursor/rules/horse-patterns.mdCursor rule
- .cursor/rules/intraweb-patterns.mdCursor rule
- .cursor/rules/memory-exceptions.mdCursor rule
- .cursor/rules/mysql-patterns.mdCursor rule
- .cursor/rules/postgresql-patterns.mdCursor rule
- .cursor/rules/refactoring.mdCursor rule
- .cursor/rules/solid-patterns.mdCursor rule
- .cursor/rules/tdd-patterns.mdCursor rule
- .cursor/rules/threading-patterns.mdCursor rule
- acbr-componentsSkill
- Delphi Clean CodeSkill
- Delphi Code ReviewSkill
- Delphi Memory and ExceptionsSkill
- Delphi SOLID PatternsSkill
- Design Patterns GoF — DelphiSkill
- DevExpress/DEXT ComponentsSkill
- Dext Framework PatternsSkill
- DelphiMVCFrameworkSkill
- DUnitX Testing PatternsSkill
- Firebird DatabaseSkill
- Intraweb FrameworkSkill
- MySQL DatabaseSkill
- PostgreSQL DatabaseSkill
- Delphi Code RefactoringSkill
- Delphi Test-Driven Development (TDD) and DUnitXSkill
- Threading & Multi-ThreadingSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use this skill when creating REST APIs with the Horse framework in Delphi.
- Distinctive: line 12
When creating a new REST API project
- Distinctive: line 13
When adding routes and endpoints
- Distinctive: line 14
When implementing middleware (JWT, CORS, logging)
- Distinctive: line 15
When integrating Horse with FireDAC
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Horse Framework — Skill
Use this skill when creating REST APIs with the Horse framework in Delphi.
When to Use
- When creating a new REST API project
- When adding routes and endpoints
- When implementing middleware (JWT, CORS, logging)
- When integrating Horse with FireDAC
About Horse
Horse is a minimalist and performant REST framework for Delphi, inspired by Express.js (Node.js). It uses the middleware chain concept and is extremely simple to configure.
- Repository: github.com/HashLoad/horse
- Installation: Boss (
boss install horse) or manual
Project Structure
src/
├── MeuApp.dpr ← Projeto principal
├── Controllers/
│ ├── MeuApp.Controller.Customer.pas
│ ├── MeuApp.Controller.Product.pas
│ └── MeuApp.Controller.Health.pas
├── Middleware/
│ ├── MeuApp.Middleware.Auth.pas
│ ├── MeuApp.Middleware.Logger.pas
│ └── MeuApp.Middleware.CORS.pas
├── Domain/
│ ├── MeuApp.Domain.Customer.Entity.pas
│ └── MeuApp.Domain.Customer.Repository.Intf.pas
├── Application/
│ └── MeuApp.Application.Customer.Service.pas
├── Infrastructure/
│ └── MeuApp.Infra.Customer.Repository.pas
└── Config/
└── MeuApp.Config.Server.pasBasic Server Configuration
program MeuApp;
{$APPTYPE CONSOLE}
uses
Horse,
Horse.Jhonson, //JSON middleware
Horse.CORS, //CORS middleware
Horse.HandleException,
MeuApp.Controller.Customer,
MeuApp.Controller.Health;
begin
THorse.Use(Jhonson);
THorse.Use(CORS);
THorse.Use(HandleException);
//Register broken
TCustomerController.RegisterRoutes;
THealthController.RegisterRoutes;
THorse.Listen(9000,
procedure
begin
Writeln('Server running on port 9000');
end
);
end.Controller Pattern
unit MeuApp.Controller.Customer;
interface
uses
Horse,
System.JSON;
type
TCustomerController = class
public
class procedure RegisterRoutes;
private
class procedure GetAll(AReq: THorseRequest; ARes: THorseResponse; ANext: TProc);
class procedure GetById(AReq: THorseRequest; ARes: THorseResponse; ANext: TProc);
class procedure Create(AReq: THorseRequest; ARes: THorseResponse; ANext: TProc);
class procedure Update(AReq: THorseRequest; ARes: THorseResponse; ANext: TProc);
class procedure Delete(AReq: THorseRequest; ARes: THorseResponse; ANext: TProc);
end;
implementation
uses
System.SysUtils,
MeuApp.Application.Customer.Service.Intf;
class procedure TCustomerController.RegisterRoutes;
begin
THorse.Get('/api/customers', GetAll);
THorse.Get('/api/customers/:id', GetById);
THorse.Post('/api/customers', Create);
THorse.Put('/api/customers/:id', Update);
THorse.Delete('/api/customers/:id', Delete);
end;
class procedure TCustomerController.GetAll(
AReq: THorseRequest; ARes: THorseResponse; ANext: TProc);
var
LService: ICustomerService;
LResult: TJSONArray;
begin
LService := TServiceFactory.CreateCustomerService;
LResult := LService.GetAllAsJSON;
ARes.Send<TJSONArray>(LResult).Status(THTTPStatus.OK);
end;
class procedure TCustomerController.GetById(
AReq: THorseRequest; ARes: THorseResponse; ANext: TProc);
var
LService: ICustomerService;
LId: Integer;
LResult: TJSONObject;
begin
LId := AReq.Params['id'].ToInteger;
LService := TServiceFactory.CreateCustomerService;
LResult := LService.GetByIdAsJSON(LId);
if not Assigned(LResult) then
begin
ARes.Send('Customer not found').Status(THTTPStatus.NotFound);
Exit;
end;
ARes.Send<TJSONObject>(LResult).Status(THTTPStatus.OK);
end;
class procedure TCustomerController.Create(
AReq: THorseRequest; ARes: THorseResponse; ANext: TProc);
var
LService: ICustomerService;
LBody: TJSONObject;
begin
LBody := AReq.Body<TJSONObject>;
LService := TServiceFactory.CreateCustomerService;
try
LService.CreateFromJSON(LBody);
ARes.Send('Created').Status(THTTPStatus.Created);
except
on E: EValidationException do
ARes.Send(E.Message).Status(THTTPStatus.BadRequest);
on E: EBusinessRuleException do
ARes.Send(E.Message).Status(THTTPStatus.Conflict);
end;
end;Custom Middleware
unit MeuApp.Middleware.Auth;
interface
uses
Horse;
procedure AuthMiddleware(AReq: THorseRequest; ARes: THorseResponse; ANext: TProc);
implementation
uses
System.SysUtils,
Horse.JWT;
procedure AuthMiddleware(AReq: THorseRequest; ARes: THorseResponse; ANext: TProc);
var
LToken: string;
begin
LToken := AReq.Headers['Authorization'];
if LToken.IsEmpty then
begin
ARes.Send('Token not provided').Status(THTTPStatus.Unauthorized);
Exit;
end;
//Validar token JWT
if not ValidateJWTToken(LToken) then
begin
ARes.Send('Invalid token').Status(THTTPStatus.Unauthorized);
Exit;
end;
ANext; //continue to the next handler
end;
end.Logger Middleware
unit MeuApp.Middleware.Logger;
interface
uses
Horse;
procedure LoggerMiddleware(AReq: THorseRequest; ARes: THorseResponse; ANext: TProc);
implementation
uses
System.SysUtils,
System.DateUtils;
procedure LoggerMiddleware(AReq: THorseRequest; ARes: THorseResponse; ANext: TProc);
var
LStartTime: TDateTime;
begin
LStartTime := Now;
Writeln(Format('[%s] %s %s',
[FormatDateTime('hh:nn:ss', Now),
AReq.MethodType.ToString,
AReq.RawWebRequest.PathInfo]));
ANext;
Writeln(Format('[%s] Completed in %dms',
[FormatDateTime('hh:nn:ss', Now),
MilliSecondsBetween(Now, LStartTime)]));
end;
end.Conventions for Horse
| Appearance | Convention |
| URLs | Kebab-case, plural: /api/customers, /api/order-items |
| HTTP Methods | GET (list/search), POST (create), PUT (update), DELETE (remove) |
| Status | 200 OK, 201 Created, 400 Bad Request, 404 Not Found, 500 Internal |
| Response | Always JSON via Jhonson middleware |
| Controller | Static class methods with RegisterRoutes |
| Middleware | Standalone procedures or class methods |
| Parameters | Path: AReq.Params['id'], Query: AReq.Query['search'] |
Horse Add-on Packages
| Package | Usage | Boss Installation |
horse-jhonson | JSON middleware | boss install horse-jhonson |
horse-cors | CORS | boss install horse-cors |
horse-jwt | JWT Authentication | boss install horse-jwt |
horse-basic-auth | Basic Auth | boss install horse-basic-auth |
horse-handle-exception | Error handler | boss install horse-handle-exception |
horse-octet-stream | Upload/download | boss install horse-octet-stream |
Checklist for Horse Projects
Jhonsonregistered middleware for automatic JSON?CORSregistered middleware?HandleExceptionmiddleware for error handling?- Routes follow RESTful convention (plural, kebab-case)?
- Controllers use Services (do not access direct repository)?
- Guard clauses in handlers before logic?
- Correct HTTP status in responses?
- Integration tests with
TRESTClientsimulating calls?
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

