0

I want to implement a reverse proxy in the Nameko framework but I don’t know how I can do it. I did it in the FastApi framework:

@app.get("/test")
async def proxy(request: Request):
try:
    os_headers = []
   
    HTTP_SERVER = AsyncClient(base_url="http://127.0.0.1:5000/login",timeout=1000.0)
    url = httpx.URL(path='', query=request.url.query.encode("utf-8"))
    rp_req = HTTP_SERVER.build_request(
        request.method, url, headers=os_headers, content=await request.body()
    )
    rp_resp = await HTTP_SERVER.send(rp_req, stream=True)
    return StreamingResponse(
        rp_resp.aiter_raw(),
        status_code=rp_resp.status_code,
        headers=rp_resp.headers,
        background=BackgroundTask(rp_resp.aclose),
    )
except Exception as e :
    print( e)

How can I do the same thing in Nameko?

Alihossein shahabi
  • 4,034
  • 2
  • 33
  • 53

0 Answers0