#1 2017-06-08 08:58:37

mattsbg
Member
Registered: 2017-05-23
Posts: 20

Proxying requests to Mormot HTTP Server

Hi,

We are porting our legacy application to mormot using the database layer, but not the ORM part.

We want to implement the http connection using our own SynDB HTTP Server. As a special requirement we want to redirect/proxy SQL commands affecting certain tables to a central system.

We figured out that TSQLDBServerHttpApi should be a good point to start.

What would be the right place for implementing an inspection of the SQL-Statement or HTTP-Request to decide whether it has to be redirected or not.
How could we do a redirection and properly hand over the THttpServerRequest to the uplink server?

thanks,
Matt

Offline

#2 2017-07-20 11:56:10

mattsbg
Member
Registered: 2017-05-23
Posts: 20

Re: Proxying requests to Mormot HTTP Server

Hi,

as we succeeded in integrating this, I wanted to share our solution. Maybe someday it's useful to someone other.

The key was that all requests are handled by the SynDb.TSQLDbConnection.RemoteProcessMessage method. Instead of just letting the connection create the NewPreparedStatement we called our newly introduced template method, inherited the connection and implemented our template method. In this template method we decide whether the request can be handled locally or we inject our own new statement instance, which is a RemoteStatement again. Nothing more to change and it really works like a charme.

Only transactions aren't duplicated in this scenario, but we don't need in this particular case. If anyone has an idea of how to easily add this functionality, it's welcome ;-)

thanks,
Matt

Offline

Board footer

Powered by FluxBB