The independent file on technology, travel & lifeFrom Pakistan, for everywhere
Huzi Blogs.
The ArchiveSectionsSearch

Planning a trip? HTG Travels — flights, visas, hotels & Umrah, handled properly.

WhatsApp +92 317 5054959
Huzi Blogs.

An independent file on technology, travel and life — long-form guides written plainly, from Pakistan, for everywhere.

ShopMeet the Creator

Sections

  • Travel
  • Technology
  • Lifestyle
  • Programming
  • Sports
  • Linux
  • All sections

The Desk

  • The Archive
  • Search the file
  • Disclaimer & Data Privacy Policy
  • A project of huzi.pk

© 2026 blogs.huzi.pk — All rights reserved.

Set in Playfair Display & Inter

    HomeWeb DevelopmentStory
    Web Development

    API Gateway Patterns 2026: The Complete Problem-Solving Guide

    H

    By Huzi

    File #546 · 4 min read

    Your checkout screen calls /orders, then /inventory, then /payments, then /users — four microservices, each with its own JWT verification, its own rate limiter, its own CORS config. Half the codebase is duplicated plumbing, and a single auth fix has to ship through a dozen repos.

    The quick answer: the gateway pattern answers this — one hardened front door that terminates TLS, checks credentials, applies limits and routes inward, so the services behind it stay thin. Verify the JWT once at the edge, share rate-limit counters in Redis, and keep business rules out of plugins.

    What the gateway owns

    Cross-cutting concerns live at the edge, once: TLS termination, authentication, rate limiting, structured access logs, CORS, tracing headers.

    Clients get a single entry point — one hostname instead of twenty, one certificate to rotate, one firewall rule to reason about. Services behind it accept traffic only from the gateway and trust the identity headers it injects.

    Routing, declared not coded

    Kong in DB-less mode reads routes from YAML: every change is reviewable in a pull request, and a bad deploy is a git revert away:

    # kong.yml — declarative routing
    _format_version: "3.0"
    services:
      - name: orders-service
        url: http://orders.svc.cluster.local:8080
        routes:
          - name: orders-route
            paths: ["/api/orders"]
            strip_path: true
      - name: users-service
        url: http://users.svc.cluster.local:8080
        routes:
          - name: users-route
            paths: ["/api/users"]
            strip_path: true
    

    Run it with docker-compose (image kong:3.7, KONG_DATABASE: off, that config mounted read-only) and you have a working gateway on your laptop in five minutes.

    Auth offloading

    Verify the JWT once at the edge, then forward the identity as trusted headers. The check is three steps — decode, verify the signature against the issuer's public key, reject on expiry.

    Use RS256 in production; a shared HS256 secret across services means one leak burns every service at once. Kong's jwt plugin handles the verification, and the request-transformer plugin copies verified claims into X-User-Id and X-Tenant-Id headers, so downstream logs never contain a token.

    The whole scheme rests on one rule: network policy must guarantee that only the gateway can reach the services. Otherwise anyone inside the cluster injects X-User-Id: admin and walks past everything.

    Auth offload has a travel twin: verify the traveller once, then let every downstream leg trust the file. That is how HTG Travels handles a family's documents — checked once at the Sialkot desk, trusted by every airline and hotel downstream.

    Rate limits that survive scale

    Two rules: limit by consumer, never by IP — corporate NAT punishes honest users while botnets rotate addresses — and when you run two gateway instances, in-memory counters diverge, making the real limit configured times instance count. Share the counter:

    plugins:
      - name: rate-limiting
        route: orders-route
        config:
          minute: 100
          policy: redis
          redis_host: redis.data.svc.cluster.local
          fault_tolerant: true
    

    One Redis round-trip per request buys correctness across every instance. Token bucket suits bursty human traffic; leaky bucket protects a downstream that cannot tolerate bursts at all.

    Keep the door thin

    Gateway job In practice The trap
    Routing Kong DB-less YAML, reviewable in PRs Config edited live through the admin API
    Auth offload Verify the JWT once, forward trusted headers Without network policy, anyone inside injects X-User-Id: admin
    Rate limiting Limit by consumer, share counters via Redis By-IP limits punish corporate NAT; in-memory counters diverge
    Staying thin Business rules live in services, not plugins Lua creeping past a couple of hundred lines

    Two failure modes recur. The gateway becomes a monolith the day business rules creep in, and config edited live through the admin API is an outage waiting for a Friday afternoon: keep the YAML in Git and sync it from CI with deck.

    Kong suits self-hosted plugin-heavy estates, AWS API Gateway suits the all-in-managed crowd, Envoy fits when a service mesh is already in the picture.

    Pro tip: If your plugin Lua grows past a couple of hundred lines, move it — approval limits and pricing tiers belong in a service, not a plugin.

    Routing around failure is our daily trade. When an airline cancels the overnight departure and strands half an Umrah group in Jeddah, we reroute at HTG Travels — rebook, re-file, find the next path to Makkah — because travellers should never see the plumbing. Message +92 317 5054959 when the backlog clears.

    In Gaza the crossing itself is the closed route, and families wait outside it — may that door open soon.

    Presented by

    HTG Travels — Plan the Trip, Skip the Runaround

    Flights, visas, Umrah packages and Hunza–Skardu tours, handled end to end from our licensed Sialkot desk. Real fares, hotel names in writing, and a human who answers — before you pay a rupee.

    Flights & rebooking Visa files Umrah 2026–27 Northern tours
    Visit htg.com.pkWhatsApp +92 317 5054959

    Sialkot, Pakistan · Licensed agency · Fast quotes on WhatsApp


    You Might Also Like

    Premium Schiffli Embroidered Cotton Suit 3-Pc | Digital Print Silk Dupatta & Tassels (2025)

    Premium Schiffli Embroidered Cotton Suit 3-Pc | Digital Print Silk Dupatta & Tassels (2025)

    PKR 8800

    Handwork Heavy Embroidered Chiffon Party Wear Suit (Peach/Pink)

    Handwork Heavy Embroidered Chiffon Party Wear Suit (Peach/Pink)

    PKR 5300

    Heavy Embroidered Organza Wedding Dress 2026 with Handwork & Pearls

    Heavy Embroidered Organza Wedding Dress 2026 with Handwork & Pearls

    PKR 5500

    Elegant Printed Swiss Lawn Dress 3-Pc | Digital Print Silk Dupatta (2024)

    Elegant Printed Swiss Lawn Dress 3-Pc | Digital Print Silk Dupatta (2024)

    PKR 3950

    Elegant Printed Embroidered Lawn Suit 3-Pc | Printed Chiffon Dupatta

    Elegant Printed Embroidered Lawn Suit 3-Pc | Printed Chiffon Dupatta

    PKR 4600

    Keep reading

    Related files

    Web Development

    GraphQL vs REST API Design 2026: The Complete Problem-Solving Guide

    The honest decision guide for 2026: when REST wins, when GraphQL wins, what each one costs you in caching, security and operations, and how to migrate screen by screen without a rewrite.

    By HuziFile #539

    Read
    Web Development

    Vite + React Performance 2026: The Complete Problem-Solving Guide

    Measure the three Core Web Vitals, split routes and vendor chunks, tree-shake the imports that eat your bundle, let the React Compiler do the memo work, and fix images before JavaScript.

    By HuziFile #542

    Read
    Web Development

    WebSockets Real-Time Apps 2026: The Complete Problem-Solving Guide

    The production side of WebSockets: sticky sessions versus the Redis adapter, backpressure from slow clients, heartbeats, honest reconnection and delivery guarantees past a single node.

    By HuziFile #540

    Read
    Web Development

    Next.js 16 Server Actions: The Complete 2026 Problem-Solving Guide

    The Server Actions deep end: one function wired straight to your form, useActionState for errors and pending flags, revalidatePath vs revalidateTag, and the security rules people learn too late.

    By HuziFile #529

    Read
    Web Development

    Web Dev Frameworks in 2026: Next.js 16 vs Astro 5 vs SvelteKit 2 vs Remix

    The 2026 framework verdict without the hype: Next.js 16 for applications, Astro 5 for content, SvelteKit 2 for performance, Remix merged into React Router v7 — with hosting costs in rupees.

    By HuziFile #511

    Read
    Web Development

    Getting Started with React 19: A Beginner's Guide for 2026

    The one-evening React quickstart: scaffold with Vite, write your first component and a click counter, then deploy before bed — every command included, nothing else needed.

    By HuziFile #192

    Read
    Back to the archive