Question

My application consists of a 'gateway' DataSnap REST server that is the first point of access for all clients. Depending on the username the clients pass in their requests (basic authentication), the request needs to be redirected to another DataSnap server. My question - is there anyway of building the 'gateway' server so that it simply redirects whatever the request is to another server based on the username, or other values in the HTTP request headers? I'm trying to avoid having to repeat all the server methods in the 'gateway' service i.e. I'd rather not 'chain' 2 requests together but somehow just have 1 request redirected.

Not sure if this is possible, but thought somebody might prove me wrong? I'm using Delphi XE2 and the DataSnap servers are Windows services.

Was it helpful?

Solution 2

Short version: the solution will depend on which level (HTTP, DataSnap, in between) you know where to target the request to.

If you can make the decision on the DataSnap level, there are two kinds of solutions:

  • The purists way to do this is write a generic DataSnap gateway that can interrogate a datasnap target server, dynamically creates both a proxy server and client for it, then intercepts the traffic and decides which datasnap target server to hand over the request to.
  • A more pragmatic approach would be the one you are afraid of.

Another approach would be on the HTTP level. That will only work if you can determine at the HTTP level to which target server a request should be handed over to.

OTHER TIPS

I can see two options here:

  • use the first server only to return the address of the real server after logging in

or

  • use a Apache or NGINX reverse proxy in front of the Datasnap servers and RewriteRules based on the authentication data (however my Google-Fu for today seems to be exhausted, maybe this can be placed as a HTTP / Apache specfifc question here on SO)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top