On Fri, Apr 04, 2025 at 04:01:56AM -0700, 'Alexander Ertli' via golang-nuts
wrote:
> Instead of the nested ServeMux executing its registered handlers for the
> stripped path, it consistently returns a 301 Moved Permanently redirect to
> the stripped path itself.
> // This should remove "/api/" before innerMux sees the request.
> outerMux.Handle("/api/", http.StripPrefix("/api/", innerMux))
You are stripping too much though.
Your request going in looks like `GET /api/test`, after stripping however you
end up with `GET test`, note the lack of an initial root slash.
That's normally ok if you directly pass it to the handler, but you have a mux
there
that expects to be at the root. Meaning sane requests must start with a root.
Removing the trailing slash from the stripPrefix makes it work, or just stop
chaining muxers I guess.
> outerMux.Handle("/api/", http.StripPrefix("/api", innerMux))
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/golang-nuts/szz75o7ftb4uqs3ucnfuybrgydeyauletm5z57lieoaatovohr%40jbwlnmd6hvay.