Trying to figure out if it is possible to make multiple backend API calls when a single call comes into caddy endpoint. Given the caddy configuration for port 2016 and 2017 (in CaddyFile section), when I invoke
curl -k https://localhost:2018
I would like to see the following output (i.e. caddy calls both endpoints, one after the other)
localhost:2016 {
respond "Goodbye, world! (localhost:2016)"
}
localhost:2017 {
respond "Goodbye, world! (localhost:2017)"
}
localhost:2018 {
?? Not sure how to structure this so that it calls both localhost:2017 and localhost:2016 ??
}
I was trying to simulate the presence of an API gateway in the caddy server during my API development. Not sure if this is legitimate request for caddy server or not. But here is the scenario if you want to pursue this work (assuming this is not possible today).
Client app obtains an access token from Authorization server on behalf of the user.
Client app makes a call to service A with the access token
API gateway receives the request of service A and extracts the access token.
API gateway invokes backend token validation service with this token via reverse proxy and gets custom API authorizations.
If API gateway gets an error (either because token is invalid or expired etc.), then it will reject the request right here. Otherwise, it will proceed to the next step.
API gateway includes these custom authorizations on the request and forwards the client request to the actual service A implementation (again via reverse-proxy mechanism)
The service A implementation checks these custom authorizations and decides to process the request or not (There by not having to deal with how to validate access token and getting authorizations etc.)
Are you basically looking for something like Kong? I’ve thought about a Caddy module to do that kind of thing but have debated as to whether users would find it useful and whether it’d be generally useful enough.
I was merely attempting to see if this is possible with caddy server or not, since caddy server is so light weight to get it working natively on windows, especially for development.