Hi everyone,
I have a backend written in Python and a Frontend written in _javascript_.
What I'd like to do is setup a configuration such that when a request comes through, it is first sent to the backend, then the response from the backend is sent to the frontend.
The backend application is a web server, the front-end application listens for input on unix domain socket.
My question is: is it possible to take the output stream from the backend server response, and send that as stdin to the frontend application and then send that response back to the client?
I've used Nginx for many years, but I am new to open resty.
In a real world use case, I would detect GET requests that were sent via XHR and only send them to the backend. If it were a GET request not sent via XHR, I would want to do this "piping" approach of sending the output from the backend app to the frondend app before sending a fully rendered page down to the client.
I think this approach has some interesting benefits, as it would a allow for server-side rendering of pages that use _javascript_ technology (such as React JS) without the backend application needing to know in any way what sort of frontend application it may be working with.
Currently, many people are using Python, Ruby, PHP etc to send their backend response to a _javascript_ rendering script, but this is a condition in the backend code where the backend will open this connection, and it will send the response back. While this may not seem overly problematic, it makes the backend and frontend coupled together. I'd like to have the flexibility to have many frontend applications that can render pages on the server side without the backend having any knowledge of who or what application is consuming the data.
Eagerly awaiting your thoughts on this.
Best,
Ryan