Rewrite requests

Job: point production URLs and tokens at staging values without writing middleware.

sudo gor --input-raw :8080 --output-http="http://staging.example.com" \
  --http-rewrite-url '/v1/user/([^\/]+)/ping:/v2/user/$1/ping' \
  --http-set-param api_key=1 \
  --http-set-header 'User-Agent: Gor'
  • --http-rewrite-url src:replacement — regexp, $1 groups. Colon splits src and replacement.
  • --http-set-param key=value — overwrite or add a query param.
  • --http-set-header 'Name: value' — overwrite or add a header.
  • --http-rewrite-header 'Host: (.*).example.com,$1.beta.example.com' — header name, then regexp,target.

Host

Default: Host becomes the --output-http host. --http-original-host leaves Host alone (multi-tenant apps). A manual --http-set-header Host: ... also disables the automatic replace.

If staging is HTTPS and production was HTTP, set the output URL scheme correctly and do not assume Host rewrite fixes TLS SNI.

Custom logic: middleware.