I have two different machines, each running same FastAPI() application, started with unicorn on port 3000. I am not sure what is the right approach to duplicate each route from the first server to the second one..
For example when the first server get
@router.post("/register_book")
async def register_book(
request: RegisterBookRequest, db)
) -> Response:
....
What I look for is a way, that not only first server will proceed this request, but also same request will be sent from server A to server B.. something like
@router.post("/register_book")
async def register_book(
request: RegisterBookRequest, db)
) -> Response:
....
// initiate the same synchronous request to <second server IP>:3000, wait for response
Any ideas? The best I guess something like
@router.post("/register_book")
@something.dupliate.request("<second_server_ip>:3000")
async def register_book(
request: RegisterBookRequest, db)
) -> Response:
....
but I doubt it possible..thanks
You can create middleware.