Reverse engineered prompt

GitHub

Build me a small C++17 API gateway I can run locally to test basic traffic handling. I want one public server on port 8080 that forwards requests to backend services based on the path. Requests under /api/v1/users/ should go to two user service instances on ports 5001 and 5002, and /api/v1/orders/ should go to two order service instances on ports 6001 and 6002. It should spread traffic in round robin so repeated calls alternate between the two servers in each group.

Please add a simple rate limiter using a token bucket per client, with 5 requests allowed right away and 1 token added back each second. If a client goes over the limit, return 429 with a clear JSON error. Unknown routes should return 404, and if a backend is down or times out, return 502 instead of crashing.

Include tiny mock backend servers so I can see which port handled each request, plus a CMake setup and easy run steps. Look up current docs online if you need to.

Have a live product UI? Try website reverse