Skip to content

Feature Request: Support route rewrite in http gateway mappings #5134

@maomao94

Description

@maomao94

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions