بنقرة واحدة
horse-minimal-api
Guide for building lightweight, low-boilerplate, and rapid HTTP services (Minimal APIs) in Horse.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Guide for building lightweight, low-boilerplate, and rapid HTTP services (Minimal APIs) in Horse.
التثبيت باستخدام 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-minimal-api |
| description | Guide for building lightweight, low-boilerplate, and rapid HTTP services (Minimal APIs) in Horse. |
For focused microservices, mock APIs, or rapid prototyping, you can leverage Horse's lightweight routing and configuration DSL to build complete HTTP services in a single file with minimal boilerplate.
A Minimal API structures all route registrations, basic logic, and middleware imports directly within the main .dpr bootstrap file using inline anonymous procedures:
program MinimalAPI;
{$APPTYPE CONSOLE}
uses
System.SysUtils,
System.JSON,
Horse,
Horse.Jhonson;
begin
// 1. Fluent Middleware Configuration
THorse.Use(Jhonson);
// 2. Inline Route Mappings
THorse.Get('/ping',
procedure(Req: THorseRequest; Res: THorseResponse)
begin
Res.Send('pong');
end);
THorse.Get('/hello/:name',
procedure(Req: THorseRequest; Res: THorseResponse)
begin
Res.Send('Hello, ' + Req.Params.Field('name').AsString + '!');
end);
// 3. Fast JSON response
THorse.Get('/status',
procedure(Req: THorseRequest; Res: THorseResponse)
var
LStatus: TJSONObject;
begin
LStatus := TJSONObject.Create(TJSONPair.Create('status', 'online'));
Res.Send(LStatus); // Johnson takes ownership
end);
// 4. Port Listening
THorse.Listen(9000);
end.
Although Minimal APIs promote rapid development, follow these principles to avoid "spaghetti code":
THorse.UseRadixRouter; to ensure maximum matching speed if your API contains path parameters.Transition from a Minimal API to a structured MVC/Modular architecture when:
.dpr file.