#5134·go-zero

Feature Request: Support route rewrite in http gateway mappings

Author: maomao94Created Aug 30, 2025Updated Sep 16, 2026
Labelsstale

Currently, the http gateway in go-zero only supports Path and Method in Mappings, but there is no way to rewrite the route before forwarding to the upstream service.

In many real-world cases, the public API path exposed by the gateway is different from the actual path required by the downstream service. Supporting Rewrite would make the gateway much more flexible.

Example
Upstreams:
  - Name: external-cable
    Http:
      Target: localhost:19103
      Timeout: 15000
    Mappings:
      - Method: POST
        Path: /api/abandoned/external/cable/workList
        Rewrite: /cable/workList

With this configuration:

The gateway exposes:

POST /api/abandoned/external/cable/workList

But it rewrites and forwards the request to:

POST http://localhost:19103/cable/workList