Skip to content

reverse

reverse provides a mounted reverse HTTP proxy handler with:

  • target resolution
  • path and query merging
  • hop-by-hop header stripping
  • request and response mutation hooks
  • neutral observation hooks

Use it for

  • /proxy/...?_target=https://upstream.example
  • reverse-proxy adapters in debuggers or developer tools
  • product-specific reverse proxy endpoints without hard-coding those routes into the library

Main entry point

go
handler, err := reverse.New(reverse.Options{
  Resolver: reverse.QueryTargetResolver{
    MountPath: "/proxy",
  },
})

Important options

OptionMeaning
ResolverRequired target resolver
RoundTripperCustom http.RoundTripper
MutateRequestRequest mutation before transport round trip
MutateResponseResponse mutation before response is copied downstream
HooksShared observation hooks
ObserveTargetPredicate to suppress observation for selected targets
PreserveHostKeep incoming Host instead of replacing with upstream host
SampleRequestBodyBytesSample limit for observed request body
SampleResponseBodyBytesSample limit for observed response body

Built-in resolver

QueryTargetResolver resolves _target, applies an optional default target, strips selected query parameters, and merges the request path and query into the upstream URL.

That gives you mounted reverse-proxy behavior without forcing route names into the package itself.

Released under the Apache 2.0 License.