2025-06-03 16:39:17 +02:00
# Furt API Gateway
2025-08-14 09:36:55 +02:00
**HTTP-Server in Lua für Service-Integration**
2025-06-03 16:39:17 +02:00
## Überblick
2025-08-14 09:36:55 +02:00
Furt ist ein HTTP-Server der verschiedene Services unter einer API vereint. Aktuell unterstützt es Mail-Versendung über SMTP und bietet eine einfache JSON-API für Web-Integration.
2025-06-03 16:39:17 +02:00
2025-08-14 09:36:55 +02:00
## Features
2025-06-17 20:40:40 +02:00
2025-08-14 09:36:55 +02:00
- HTTP-Server mit JSON-APIs
- Mail-Versendung über SMTP
- Request-Routing und Authentication
- Health-Check-Endpoints
- Konfigurierbare Rate-Limiting
- Hugo/Website-Integration
2025-06-17 20:40:40 +02:00
2025-08-14 09:36:55 +02:00
## Dependencies
2025-06-17 20:40:40 +02:00
2025-08-14 09:36:55 +02:00
**Erforderlich:**
- `lua` 5.4+
- `lua-socket` (HTTP-Server)
- `lua-cjson` (JSON-Verarbeitung)
2025-06-17 20:40:40 +02:00
2025-08-14 09:36:55 +02:00
**Installation:**
2025-06-17 20:40:40 +02:00
```bash
2025-08-14 09:36:55 +02:00
# Arch Linux
pacman -S lua lua-socket lua-cjson
2025-06-17 20:40:40 +02:00
2025-08-14 09:36:55 +02:00
# Ubuntu/Debian
apt install lua5.4 lua-socket lua-cjson
```
2025-06-03 16:39:17 +02:00
2025-08-14 09:36:55 +02:00
## Installation
2025-06-03 16:39:17 +02:00
2025-08-14 09:36:55 +02:00
```bash
# Repository klonen
git clone < repository-url >
cd furt
2025-06-03 16:39:17 +02:00
2025-08-14 09:36:55 +02:00
# Scripts ausführbar machen
chmod +x scripts/*.sh
2025-06-03 16:39:17 +02:00
2025-08-14 09:36:55 +02:00
# Server starten
./scripts/start.sh
```
2025-06-03 16:39:17 +02:00
2025-08-14 09:36:55 +02:00
**Server läuft auf:** http://127.0.0.1:8080
2025-06-17 20:40:40 +02:00
2025-08-14 09:36:55 +02:00
## API-Endpoints
2025-06-17 20:40:40 +02:00
2025-08-14 09:36:55 +02:00
### Health Check
```bash
GET /health
→ {"status":"healthy","service":"furt","version":"1.0.0"}
```
2025-06-17 20:40:40 +02:00
2025-08-14 09:36:55 +02:00
### Mail senden
2025-06-17 20:40:40 +02:00
```bash
2025-08-14 09:36:55 +02:00
POST /v1/mail/send
Content-Type: application/json
2025-06-17 20:40:40 +02:00
2025-08-14 09:36:55 +02:00
{
"name": "Name",
"email": "sender@example .com",
"message": "Nachricht"
}
2025-06-17 20:40:40 +02:00
2025-08-14 09:36:55 +02:00
→ {"success":true,"message":"Mail sent"}
2025-06-17 20:40:40 +02:00
```
2025-08-14 09:36:55 +02:00
## Konfiguration
2025-06-03 16:39:17 +02:00
2025-08-14 09:36:55 +02:00
**Environment Variables (.env):**
```bash
FURT_MAIL_HOST=mail.example.com
FURT_MAIL_PORT=587
FURT_MAIL_USERNAME=user@example .com
FURT_MAIL_PASSWORD=password
FURT_MAIL_TO=empfaenger@example .com
2025-06-17 20:40:40 +02:00
```
2025-06-03 16:39:17 +02:00
2025-08-14 09:36:55 +02:00
**Server-Config (config/server.lua):**
- Port und Host-Einstellungen
- API-Key-Konfiguration
- Rate-Limiting-Parameter
2025-06-03 16:39:17 +02:00
2025-08-14 09:36:55 +02:00
## Testing
2025-06-03 16:39:17 +02:00
2025-08-14 09:36:55 +02:00
**Automatische Tests:**
```bash
lua tests/test_http.lua
```
2025-06-17 20:40:40 +02:00
2025-08-14 09:36:55 +02:00
**Manuelle Tests:**
```bash
./scripts/test_curl.sh
2025-06-17 20:40:40 +02:00
2025-08-14 09:36:55 +02:00
# Oder direkt:
curl -X POST http://127.0.0.1:8080/v1/mail/send \
-H "Content-Type: application/json" \
-d '{"name":"Test","email":"test@example .com","message":"Test"}'
```
2025-06-17 20:40:40 +02:00
2025-08-14 09:36:55 +02:00
## Deployment
2025-06-17 20:40:40 +02:00
2025-08-14 09:36:55 +02:00
**OpenBSD:**
- rc.d-Script in `deployment/openbsd/`
- Systemd-Integration über Scripts
2025-06-17 20:40:40 +02:00
2025-08-14 09:36:55 +02:00
**Production-Setup:**
```bash
# Environment-Config kopieren
cp .env.example .env.production
# → SMTP-Credentials anpassen
2025-06-17 20:40:40 +02:00
2025-08-14 09:36:55 +02:00
# Production-Mode starten
export FURT_ENV=production
./scripts/start.sh
```
2025-06-17 20:40:40 +02:00
2025-08-14 09:36:55 +02:00
## Projektstruktur
2025-06-17 20:40:40 +02:00
2025-08-14 09:36:55 +02:00
```
furt/
├── src/ # Lua-Source-Code
│ ├── main.lua # HTTP-Server
│ ├── routes/ # API-Endpoints
│ └── smtp.lua # Mail-Integration
├── config/ # Konfiguration
├── scripts/ # Start/Test-Scripts
├── tests/ # Test-Suite
└── deployment/ # System-Integration
```
2025-06-17 20:40:40 +02:00
2025-08-14 09:36:55 +02:00
## Hugo-Integration
2025-06-03 16:39:17 +02:00
2025-08-14 09:36:55 +02:00
**Shortcode-Beispiel:**
```html
< form action = "http://your-server:8080/v1/mail/send" method = "POST" >
< input name = "name" type = "text" required >
< input name = "email" type = "email" required >
< textarea name = "message" required > < / textarea >
< button type = "submit" > Senden< / button >
< / form >
```
2025-06-03 16:39:17 +02:00
2025-08-14 09:36:55 +02:00
## Development
2025-06-17 20:40:40 +02:00
2025-08-14 09:36:55 +02:00
**Code-Struktur:**
- Module unter 200 Zeilen
- Funktionen unter 50 Zeilen
- Klare Fehlerbehandlung
- Testbare Komponenten
2025-06-17 20:40:40 +02:00
2025-08-14 09:36:55 +02:00
**Dependencies minimal halten:**
- Nur lua-socket und lua-cjson
- Keine externen HTTP-Libraries
- Standard-Lua-Funktionen bevorzugen
2025-06-17 20:40:40 +02:00