When a request arrives, the gateway runs it through an ordered chain of steps before any backend sees it. First it terminates TLS so the rest of the traffic inside your network can stay plain HTTP. Then it authenticates the caller, usually by validating a JWT or an API key, and rejects anything that fails with a 401 before it ever reaches a service.
Next it applies rate limiting and quotas, often backed by Redis counters, so one noisy client cannot flood your backend. Then it matches the request path and method against a route table. A rule like POST /orders forwards to the order service, while GET /search/* forwards to the search service. The gateway rewrites the path if needed and adds headers such as the resolved user id so the downstream service does not have to re-verify the token.
Some gateways also do request aggregation. A single call from a mobile home screen might fan out to the user, orders, and recommendations services in parallel, then the gateway stitches the three responses into one payload. This pattern, often called backend for frontend, cuts the number of round trips a slow mobile connection has to make.
Finally the gateway records metrics, latency, and status codes for every call, which gives you one place to see the health of the whole API instead of scraping logs from 40 services.