원클릭으로
horse-writing-middleware
Guide to writing custom middlewares for the Horse framework, following the callback flow with the Next parameter.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Guide to writing custom middlewares for the Horse framework, following the callback flow with the Next parameter.
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-writing-middleware |
| description | Guide to writing custom middlewares for the Horse framework, following the callback flow with the Next parameter. |
A custom middleware is a procedure that receives THorseRequest, THorseResponse, and a callback procedure Next.
procedure MyCustomMiddleware(Req: THorseRequest; Res: THorseResponse; Next: TProc);
begin
// 1. Logic BEFORE the request reaches the endpoint handler
Req.Headers.AddOrSetValue('X-Processed-By', 'MyMiddleware');
// 2. Call Next to delegate execution to the subsequent middleware or route handler
Next;
// 3. Logic AFTER the route handler completes its execution
Res.Headers.AddOrSetValue('X-Execution-Finished', 'True');
end;
If a validation fails (e.g., authentication is missing), do NOT call Next. Set the status and send the response immediately. This halts the pipeline execution.
procedure AuthMiddleware(Req: THorseRequest; Res: THorseResponse; Next: TProc);
var
LToken: string;
begin
LToken := Req.Headers.Items['Authorization'];
if LToken.IsEmpty then
begin
// Halt execution by sending response and omitting the Next call
Res.Send('Unauthorized').Status(THTTPStatus.Unauthorized);
Exit;
end;
// Token is valid, proceed with pipeline
Next;
end;