원클릭으로
horse-app-structure
Guide for setting up Horse applications, bootstrap program (.dpr), basic console initialization, and registering modules.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Guide for setting up Horse applications, bootstrap program (.dpr), basic console initialization, and registering modules.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Guidelines and workflows for developing and maintaining regular expressions and optional parameter routing features in the Horse framework.
Guidelines for registering, executing, and optimizing native high-precision telemetry hooks (AddOnTelemetry) in the Horse Web Framework.
Guidelines for instantiating and configuring independent Horse server instances (THorseInstance) running concurrently on different ports.
Guide for setting up thread-safe database connection pooling (FireDAC / UniDAC) in multithreaded Horse applications.
Guide for managing request-scoped contextual services and IoC (dependency injection) in Delphi and Lazarus.
Guide to using standard Horse middlewares (CORS, Jhonson, compression, basic-auth, logger) and pipeline registration order.
| name | horse-app-structure |
| description | Guide for setting up Horse applications, bootstrap program (.dpr), basic console initialization, and registering modules. |
A standard Horse application is typically configured as a Delphi Console Application ({$APPTYPE CONSOLE}).
program MyHorseApp;
{$APPTYPE CONSOLE}
uses
System.SysUtils,
Horse,
Horse.Jhonson,
Horse.CORS;
begin
// 1. Opt-in for the High-Performance Radix Tree Router (highly recommended)
THorse.UseRadixRouter;
// 2. Register Global Middlewares
THorse
.Use(CORS)
.Use(Jhonson);
// 3. Register Routes / Controllers
THorse.Get('/ping',
procedure(Req: THorseRequest; Res: THorseResponse; Next: TProc)
begin
Res.Send('pong');
end);
// 4. Start Server with Listen Callback (prevents sequential execution blocking)
THorse.Listen(9000,
procedure
begin
Writeln('Server is running on port ' + THorse.Port.ToString);
end);
end.
For production grade projects, keep the .dpr file clean by delegating route definitions to specialized Controller classes:
Horse units).Horse is inherently multithreaded (each request runs on a separate worker thread). Accessing a database inside a route handler requires strict thread safety to avoid memory corruption, race conditions, or application crashes (Access Violations):
TFDConnection or query component in your Controller or DataModule and share it across handlers.try...finally block (Delphi XE7+ compatible):procedure GetCustomerHandler(Req: THorseRequest; Res: THorseResponse; Next: TProc);
var
LConnection: TFDConnection;
LQuery: TFDQuery;
begin
LConnection := TFDConnection.Create(nil);
LQuery := TFDQuery.Create(nil);
try
// Configure connection locally (preferably utilizing FireDAC Connection Pooling)
LConnection.ConnectionDefName := 'MyPooledConnectionDef';
LConnection.Connected := True;
LQuery.Connection := LConnection;
LQuery.SQL.Text := 'SELECT * FROM CUSTOMERS WHERE ID = :ID';
LQuery.ParamByName('ID').AsInteger := Req.Params.Field('id').AsInteger;
LQuery.Open;
Res.Send(LQuery.ToJSONArray);
finally
LQuery.Free;
LConnection.Free;
end;
end;