API网关是一个单一的入口点,位于后端服务的前面——处理路由、身份验证、速率限制等交叉关注点。它在微服务架构中尤其有用,可以集中处理常见功能。
API网关做什么
text
The API GATEWAY is a single entry point in front of backend services:
Client → API GATEWAY → ┬→ Service A
├→ Service B
└→ Service C
→ handles cross-cutting concerns in ONE place (so services don't each implement them)
→ routes requests to the right service; abstracts the backend from clients
常见网关职责
text
✓ ROUTING → direct requests to the appropriate backend service
✓ AUTHENTICATION/authorization → verify identity/permissions centrally
✓ RATE LIMITING / throttling → protect backends from abuse/overload
✓ Request/response TRANSFORMATION; protocol translation; aggregation (combine service calls)
✓ CACHING; load balancing; SSL termination
✓ LOGGING, monitoring, analytics; error handling
