No description
Find a file
2026-06-30 15:14:42 +03:00
config Initial commit: api-proxy reverse proxy service 2026-06-30 15:14:42 +03:00
middleware Initial commit: api-proxy reverse proxy service 2026-06-30 15:14:42 +03:00
proxy Initial commit: api-proxy reverse proxy service 2026-06-30 15:14:42 +03:00
.gitignore Initial commit: api-proxy reverse proxy service 2026-06-30 15:14:42 +03:00
go.mod Initial commit: api-proxy reverse proxy service 2026-06-30 15:14:42 +03:00
go.sum Initial commit: api-proxy reverse proxy service 2026-06-30 15:14:42 +03:00
main.go Initial commit: api-proxy reverse proxy service 2026-06-30 15:14:42 +03:00
README.md Initial commit: api-proxy reverse proxy service 2026-06-30 15:14:42 +03:00

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_UPSTREAM
  • API_PROXY_PORT
  • API_PROXY_TOKEN
  • API_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.