I am writing an API Gateway and it's purpose is to redirect request to different microservices given that the user has access to it.
Let's assume my Gateway is running on port 7000
. For example, user is requesting http://localhost:7000/foo/method/
and I see by looking in his JWT that he has access to microservice foo
. In this case I make the request to appropriate URL (let's say http://localhost:7001/method
) and return the body to user.
Another example, user is requesting http://localhost:7000/baz/othermethod/somelink
, in this case I would redirect to something like http://localhost:7002/othermethod/somelink
.
Point is: I want to be able to accept and process requests with various amounts of slashes, but I am not aware of a way to accomplish this or if this is even possible. Does anyone know the solution to this?
Depending on how far you are into building the gateway, It might be worth looking into something like ocelot. I've used it on some really large projects in the past, and the routing tables there should be able to handle what you're describing.