lazarus-horse-json-api
Minimal backend example using Horse middleware Jhonson with JSON storage in memory.
- Active · last change 9-2-2025
- ★ 1 on GitHub
README
Lazarus + Horse JSON API
A simple REST API built with Lazarus (Free Pascal) and the Horse framework, using the Horse.Jhonson middleware for JSON parsing.
This project is for study purposes only, demonstrating how to handle JSON data in memory without a database.
🚀 Features
- POST /users → Save JSON data in memory.
- GET /users → Retrieve the last JSON saved.
- Returns JSON responses with proper
Content-Type. - Uses
fpjsonto handle JSON objects in Free Pascal.
🛠️ Requirements
- Lazarus IDE (with Free Pascal).
- Horse Framework.
- Horse Jhonson Middleware.
▶️ Running the Project
- Clone the repository:
git clone https://github.com/GabRodrigues23/lazarus-horse-json-api.git cd lazarus-horse-json-api - Open the project in Lazarus and compile.
- Run the executable:
./backend - The API will be available at:
http://localhost:9000
📡 API Endpoints
POST /users
Save a JSON object in memory.
- Request
POST /users HTTP/1.1 Host: localhost:9000 Content-Type: application/json { "name": "Gabriel R", "age": 23 } - Response
{ "name": "Gabriel R", "age": 23 }
GET /users
Retrieve the last saved JSON.
- Request
GET /users HTTP/1.1 Host: localhost:9000 - Response (if JSON exists)
{ "name": "Gabriel R", "age": 23 } - Response (if no JSON saved yet)
{ "message": "Nenhum JSON Recebido ainda. Use o metodo POST." }
📖 Notes
- The data is stored only in memory (global variable).
- Once the server restarts, the data will be lost.
- Intended for learning and demonstration purposes only.
📜 License
MIT License. Free to use and modify for educational purposes.

