Skip to main content

Introduction to Horse

Horse is an Express.js-inspired web framework for Delphi and Lazarus, designed to ease development with a minimalist approach while delivering high performance. Built for modern Pascal development, Horse enables you to create RESTful APIs and web services quickly and efficiently.

Why Horse?

Horse brings the simplicity and elegance of modern JavaScript frameworks to the Delphi/Lazarus ecosystem:

Express-Inspired

Familiar routing and middleware patterns inspired by Express.js, making it intuitive for developers coming from Node.js

High Performance

Optimized for speed with efficient request handling and minimal overhead

Minimalist Design

Clean, simple API that gets out of your way and lets you focus on building features

Cross-Platform

Works seamlessly with both Delphi (XE7+) and Lazarus/Free Pascal

Key Features

Simple Routing

Define routes with a clean, chainable API:
THorse.Get('/users/:id', 
  procedure(Req: THorseRequest; Res: THorseResponse)
  begin
    Res.Send('User ID: ' + Req.Params['id']);
  end);

Middleware Support

Extend functionality with middleware for authentication, logging, CORS, compression, and more:
THorse.Use(Jhonson);  // JSON middleware
THorse.Use(CORS);      // CORS middleware
THorse.Use(HorseJWT('secret')); // JWT authentication

Multiple HTTP Methods

Support for all standard HTTP methods:
THorse.Get('/resource', GetHandler);
THorse.Post('/resource', PostHandler);
THorse.Put('/resource/:id', PutHandler);
THorse.Patch('/resource/:id', PatchHandler);
THorse.Delete('/resource/:id', DeleteHandler);

Flexible Deployment

Horse supports multiple deployment scenarios:
  • Console Application - Standalone server
  • VCL Application - Windows GUI application
  • Windows Service - Background service
  • ISAPI - IIS integration
  • Apache Module - Apache web server
  • CGI/FastCGI - Traditional CGI deployment
  • Daemon - Linux/Unix daemon (Lazarus)

Architecture

Horse follows a simple request-response cycle with middleware support:
Request → Middleware Chain → Route Handler → Response

Core Components

  • THorseRequest - Encapsulates incoming HTTP requests with access to headers, query parameters, body, cookies, and route parameters
  • THorseResponse - Handles outgoing responses with methods for sending content, setting status codes, headers, and redirects
  • THorseCallback - Procedure type for route handlers and middleware
  • Routing Engine - Fast route matching with parameter extraction
  • Middleware System - Extensible request/response processing pipeline

Comparison to Other Frameworks

FeatureHorseTraditional CGIRaw ISAPI
RoutingBuilt-in with parametersManual parsingManual parsing
MiddlewareYesNoNo
JSON SupportVia middlewareManualManual
Ease of UseHighLowLow
PerformanceHighMediumHigh
Code ClarityVery HighLowMedium

Ecosystem

Horse has a rich ecosystem of official and community middleware:

Official Middleware

Community Middleware

The Horse community has created additional middleware for:
  • Rate limiting
  • File uploads
  • Static file serving
  • API documentation (Swagger)
  • Socket.IO
  • Pagination
  • And many more…

License

Horse is free and open-source software licensed under the MIT License.

Getting Started

Ready to build your first Horse application?

Quick Start Guide

Get your first Horse server running in minutes

Community & Support

Join the Horse community:
Horse is actively maintained by HashLoad and a vibrant community of contributors.

Build docs developers (and LLMs) love