Thanks for your help Andy and Kevin.
I'm not actually implementing a reverse proxy, I just want to do some 'normal' URL routing where the URLs may contain consecutive slashes which I want to capture. I'm using the Gorilla mux, and assume the net/http package would do the same given the original message.
If anyone else passes along this way and is interested, this is what I've ended up doing. I want to handle urls like "/route/to/things/
http://thing-uri". (This re-direct behaviour was happening with URL-encoded components).
func HandleThing(writer http.ResponseWriter, request *http.Request, string thingUri) { ... }
type InterceptHandler struct { router *mux.Router }
func (handler *InterceptHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
if strings.HasPrefix(request.URL.Path, ROUTE_THINGS) {
thingUri := request.URL.Path[len(ROUTE_THINGS):]
HandleThing(writer, request, thingUri)
return
}
handler.router.ServeHTTP(writer, request)
}
// in main:
r := mux.NewRouter()
r.StrictSlash(false)
r.HandleFunc(OTHER_ROUTE, OtherHandleFunc)
http.ListenAndServe(serveUrl.Host, &InterceptHandler{r})