No description
- Go 100%
| config | ||
| middleware | ||
| proxy | ||
| .gitignore | ||
| go.mod | ||
| go.sum | ||
| main.go | ||
| README.md | ||
api-proxy
Локальный Go-прокси для API ai-helper. Проксирует запросы агентов OpenClaw с localhost:8085/ai-helper/* на https://asvdev.ru/api/openclaw/*, автоматически подставляя Bearer-токен.
Запуск
cd ~/web/golang/api-proxy
./api-proxy
Конфигурация
Файл config.yaml (не в git):
upstream: https://asvdev.ru
port: 8085
token: "<token>"
logRequests: true
Переменные окружения имеют приоритет:
API_PROXY_UPSTREAMAPI_PROXY_PORTAPI_PROXY_TOKENAPI_PROXY_LOG_REQUESTS
Использование агентами
Все запросы выполнять к http://localhost:8085/ai-helper/... вместо прямого обращения к https://asvdev.ru/api/openclaw/.... Прокси пробрасывает все HTTP-методы (GET, POST, PUT, DELETE), заголовки и тело запроса, включая multipart/form-data.
Примеры
# Health check
curl http://localhost:8085/health
# Health upstream через прокси
curl http://localhost:8085/ai-helper/health
# Список задач
curl http://localhost:8085/ai-helper/tasks
# Создать задачу
curl -X POST http://localhost:8085/ai-helper/tasks \
-H "Content-Type: application/json" \
-d '{"title":"Тест","description":"Проверка прокси"}'
# Загрузить отчёт
curl -X POST http://localhost:8085/ai-helper/reports \
-F "file=@report.md" \
-F "task_id=123"
Systemd
systemctl --user status api-proxy
systemctl --user restart api-proxy
systemctl --user stop api-proxy
Автозапуск при загрузке включён через loginctl enable-linger sergey.