CURRICULUM PREVIEWRevision 1 · Open for reviewReview the full course
OPTIONAL EXPLORATION10 min read

API gateway

Give clients one entry without centralizing every business rule.

Before you begincircuit-breaker

The problem and the pattern

A gateway can terminate TLS, route traffic, and apply shared request policies. Service-specific authorization and data invariants still belong in the owning service. Keep the gateway observable and redundant because its failure can affect many capabilities.

Follow the flow

Make it concrete

This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.

Focused example
text
Client → gateway
/bookings → booking service
/billing → billing service
Gateway: routing, TLS, limits
Services: resource authorization and domain rules

Trade-offs

  • A gateway simplifies client entry points.
  • It can become a bottleneck or a release dependency.
  • Use clear timeouts and avoid gateway-specific domain logic.

When to avoid it

Avoid deploying a gateway when one small service and a reverse proxy already cover the requirements.

Your turn

A gateway validates the token. May the booking service trust a user-supplied tenant header?

Reveal a worked answer

No. Forward identity only through a trusted, validated boundary and still enforce tenant membership and resource permission in booking. Strip or replace spoofable identity headers at the gateway.

Keep exploring

One more piece connected.

Mark this lesson complete when you can explain the idea.