I have a Web API which has two endpoints:
/tenant1/xxx
/tenant2/xxx
The Web API serves multiple tenants and it is hosted as a single instance. Now I have to public this Web API to the outside for using, from the third party, they don't need to know which tenant they should call, instead, they call /api/dosomething (another web API), and inside that API, I will look at the parameter and decide which tenant I should reroute. I use Ocelot as API Gateway but searching on the document I can not find the condition routing. Can anyone help me with this?
Ocelot supports DelegatingHandler which play as middleware for out-going request
Related
I joined a project, that already has built all the microservices backends, and they have many API endpoints, something like below:
example1.com/api/a
example2.com/api/b
example3.com/api/c
example4.com/api/d
Recently, the manager of the company asked me to aggregate all the endpoints into one, how can we have just one API endpoint?
Something like below:
example.com/api/a or b or c/*
Is this even possible without help of developers? I mean, no code side changes?
Some of the ideas I have are.
Nginx proxy in front
API GW (but not sure which one suite best for this)
If you just want to get one endpoint and not to aggregate and merge data in one service, AWS API Gateway will help you. It will be a single entry point for client applications and you can re-route multiple requests on multiple backend services on gateway without changing any code.
You can do some integration on API Gateway:
https://api-gw.example.com/users -> integration request on service: example1.com/api/a
https://api-gw.example.com/orders -> integration request on service: example2.com/api/b
Additionally, you can have single authorization mechanism for these resources on Gateway, like Cognito, AWS_IAM, or Custom Authorization.
If you need to aggregate some API responses, you can use lambdas or BFF Pattern.
The scenario goes something like this. I've a 3rd party system that accepts 'callback' endpoint and upon a specific event (at the 3rd party system), a new API request to my callback endpoint will be posted.
Couple of years back, I've created rest API with springboot - which exposes an endpoint that's callable and other 3rd party systems will call the API as and when needed.
Are they both same?
To answer my question, yes, both are same. I've a bit better understanding of APIs and any publicly accessible endpoint can be used as callback endpoint.
I linked some existing back-end APIs to the API Publisher.
Due to some reasons, I need to create an API without any existing back-end API for it in a specific route (for example in .../myAPI/ path). The API should do something and then return a response to user.
how can I do this using WSO2 API manager? Do I need to write a handler for it? Thanks for any help.
I want to develop an application using microservices architecture. I'm really new at microservices and until now I've only worked with monolithich approach.
What I would like to do is to have a microservice which takes care of user authentication and have Proxy APIS to authorize the requests.
Authorizing the request in the Proxy API is pretty well documented on the IdentityServer4 docs, but, when the proxy api passes the request to the end microservice how do I authorize this request?
I know that if I setup the end microservice correctly, the same token used in the proxy api can be used to authorize the request at the end microservice. But how do I pass it? Do I grab the token from the request in the Proxy API and pass it down to the end microservice just like that? is it a good practice to do this?
Or is it a better option to block the end microservice to receive only requests from my proxy apis and have no authorization logic there?
PD: I would like to use asp.net-core
I know that if I setup the end microservice correctly, the same token
used in the proxy api can be used to authorize the request at the end
microservice. But how do I pass it? Do I grab the token from the
request in the Proxy API and pass it down to the end microservice just
like that? is it a good practice to do this?
Yes, it is very common to pass the JWT (or any) to pass around, proxy --> service --> proxy --> service.
And each layer can augment the token with additional details like UniqueId (for example when a request hits the first for the first time to track the chain of interactions, circuit breakers etc)
If you are application consists of multiple languages (frameworks), this approach really helps as you don't need to reimplement the authentication in each language and let proxy handle it, this especially useful with container architecture, just make sure that you leave proxy as light weight as possible, you can look into ideas based on Lyft's Envoy proxy.
I have a web application (typical mvc webapp) that needs to call a REST API bundled in a different webapp (war file).
The first web app serves as a front to the separate REST API webapp for customers to register and view their stats, purchase plans etc. But part of the design of this webapp is that it must have example invocations to the other REST API webapp.
There are many rest clients out there, but what would be a reasonable approach to address the above?
I was thinking of using the Spring REST Template to call the REST API but from my mvc controller class in the first webapp. Is this a reasonable approach?
Once you deploy a webapp using your deployment tool of choice, you can simply call the REST URL. That's one of the great things about REST - it doesn't care about what sort of tool is calling it because it deals in a neutral medium (usually HTTP). Twitter's REST API (here) doesn't care what's calling it - in fact the beauty of it is that anyone can make an app that calls it.
So say you deployed a webapp locally to port 8080, you can just make a REST call to http://localhost:8080/firstapp/rest/foo.
If you're deployed to the World Wide Web, then just call the appropriate domain.
Yes, RestTemplate is a very convenient way for server to server REST calls. Though there are some tricks if you are going to serialize generics.