원클릭으로
horse-middlewares
Guide to using standard Horse middlewares (CORS, Jhonson, compression, basic-auth, logger) and pipeline registration order.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Guide to using standard Horse middlewares (CORS, Jhonson, compression, basic-auth, logger) and pipeline registration order.
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.
Guidelines for setting up endpoints, defining path parameters, route wildcards, and structuring HTTP controllers.
| name | horse-middlewares |
| description | Guide to using standard Horse middlewares (CORS, Jhonson, compression, basic-auth, logger) and pipeline registration order. |
Middlewares intercept and process HTTP requests/responses before reaching the endpoint handlers.
The registration order of middlewares in THorse is highly critical. Middlewares must be registered before defining any routes:
begin
// 1. Logging and Error Handling (FIRST)
THorse.Use(HandleException);
// 2. Security and Headers
THorse.Use(CORS);
// 3. Payload Compression and Formatting
THorse.Use(OctetStream);
THorse.Use(Jhonson); // Parse JSON body and format JSON response
// 4. Register Routes (AFTER all global middlewares)
TProductController.RegisterRoutes;
THorse.Listen(9000);
end;
Middlewares can be declared at three levels:
THorse.Use): Runs on every request.THorseGroup.Use): Runs on all routes inside a specific group prefix.[Middleware1, Middleware2] in the verb method).The execution order follows the nested onion pattern:
Global Middlewares → Group Middlewares → Route-level Middlewares → Final Route Handler
Always design middlewares to call Next() to pass control, or skip it to short-circuit the request (e.g., unauthorized requests).
The Jhonson middleware automatically handles JSON parsing (TJSONObject / TJSONArray) for requests and responses.
Res.Send<TJSONObject>(LJson) or Res.Send<TJSONArray>(LArray), the Johnson middleware takes ownership of that object and will automatically destroy it after sending..Free or FreeAndNil on a JSON object after sending it through Res.Send<T>. Doing so will cause a Double-Free memory corruption (Access Violation) when the middleware attempts to clean it up.Horse features a native global error handling callback (THorse.OnError). It intercepts all unhandled exceptions occurring inside any middleware or route handler.
THorse.OnError(MyGlobalErrorHandler) during application startup.EHorseCallbackInterrupted and EHorseException) are bypassed and do not trigger the global OnError callback.OnError callback itself crashes, the framework handles the crash safely and returns a structured 500 Internal Server Error response with the exception detail, protecting the socket from leaking or crashing.THorseOnError = procedure(const ARequest: THorseRequest; const AResponse: THorseResponse; const AException: Exception).