proxy-server
Use Case:
proxy-server is the service to handle request for proxy paths.
Previously every proxy paths request from api-gateway was going to tether-server but now we have created proxy-server and now proxy paths requests will be directed to proxy-server from api-gateway.
proxy-server and tether-server uses same code repository and share image-patch for deployment.
From api-gateway we have directed paths to proxy-server, some are given below:
tether/govt-apis/public
tether/epod-service/v2/integration
tether/marketplace
other requests for tether/
from api-gateway will go to tether-server.
https://jamboard.google.com/d/1D1EcErxy3aJ-3mRYY3e1FeukUnB4ymXFsW7I9D7IqGA/viewer?f=0
Configuration and Request & Response Processing:
We can add the configuration in config.json file inside 'urls
’ list inside json 'redirection-proxy
'.
context
is the path of api hit by client which is needed to be proxied to some other target.target
is the targeted host. Iftarget
is different for different types of methods then usetarget_get
/target_put
/target_delete
/target_post
.manipulateReqPath
is the name of the file in proxy-server code which has the logic for manipulating the request.manipulateResPath
is the name of the file in proxy-server code which has the logic for manipulating the response.
(If you want to manipulate request or response then only pass file name in manipulateReqPath
/manipulateResPath
. context
and target
are mandatory, others are not)
If want to use same file for all methods(POST, GET, etc) of api request, use
manipulateResPath
/manipulateReqPath
.
If request file is different for different methods, then usemanipulateReqPath_put
,manipulateReqPath_post
,etc. for request manipulation.
If response file is different for different methods, then usemanipulateResPath_put
,manipulateResPath_post
,etc. for response manipulation.
(For manipulating any specific request/response, in config if you write, say manipulateResPath_post
, then no use of passing manipulateResPath
.
Similarly for target
, in config if you write, say target_get
, then no use of passing target
.)
See example below:
Example 1:
{
"context": "/v1/user/**/status",
"target": "http://user-service",
"manipulateResPath": "getUserData",
"manipulateReqPath": "actDeactUser"
}
Example 2:
{
"context": "/v1/user/**",
"target_get": "http://eqs",
"target_put": "http://entity-service",
"target_delete": "http://user-service",
"manipulateResPath_get": "getUserData",
"manipulateReqPath_put": "updateUser",
"manipulateResPath_put": "createGetUser",
"manipulateReqPath_delete": "deleteUser",
"manipulateResPath_delete": "deleteUser"
}
Rate Limit Support:
We are using @upstash/ratelimit
package for rate limiting.
Link: https://github.com/upstash/ratelimit#example
Algorithms Supported:
FIXED_WINDOW
,SLIDING_WINDOW
,TOKEN_BUCKET
,OPEN
The details related to algorithms is given in above github link.OPEN
algorithm is used to not have rate limit for any api.If we do not want rate limit for any api then we can set also asOPEN
.
Configuration: Configurations are stored in
rateLimitConfig.json
file in json format.
How to Set Rate Limit for API:
Post your questions in the comment box to get answers from the experts who watch this page.
For engineering support: visit FT Support