mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-10-06 04:38:22 +00:00
pay-out
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
import os
|
||||
import json
|
||||
from fastapi import APIRouter, Request, BackgroundTasks, Depends
|
||||
@@ -5,6 +6,8 @@ from fastapi.responses import Response, StreamingResponse
|
||||
import httpx
|
||||
import re
|
||||
|
||||
from router.cashu import pay_out
|
||||
|
||||
from .auth import validate_bearer_key, pay_for_request, adjust_payment_for_tokens
|
||||
from .db import AsyncSession, get_session
|
||||
|
||||
@@ -143,6 +146,7 @@ async def proxy(
|
||||
key, response_json, session
|
||||
)
|
||||
response_json["cost"] = cost_data
|
||||
asyncio.create_task(pay_out(session))
|
||||
return Response(
|
||||
content=json.dumps(response_json).encode(),
|
||||
status_code=response.status_code,
|
||||
@@ -162,6 +166,7 @@ async def proxy(
|
||||
background_tasks.add_task(response.aclose)
|
||||
background_tasks.add_task(client.aclose)
|
||||
|
||||
asyncio.create_task(pay_out(session))
|
||||
return StreamingResponse(
|
||||
response.aiter_bytes(),
|
||||
status_code=response.status_code,
|
||||
|
||||
Reference in New Issue
Block a user