mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
embed: rename "httpWrapper"
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
parent
ac50ef0812
commit
f6617feb8a
@ -248,15 +248,20 @@ func (sctx *serveCtx) createMux(gwmux *gw.ServeMux, handler http.Handler) *http.
|
|||||||
return httpmux
|
return httpmux
|
||||||
}
|
}
|
||||||
|
|
||||||
// wraps HTTP multiplexer to mute requests to /v3beta
|
// wrapMux wraps HTTP multiplexer:
|
||||||
// TODO: deprecate this in 3.5 release
|
// - mutate gRPC gateway request paths
|
||||||
func wrapMux(mux *http.ServeMux) http.Handler { return &v3Mutator{mux: mux} }
|
// - check hostname whitelist
|
||||||
|
// client HTTP requests goes here first
|
||||||
|
func wrapMux(mux *http.ServeMux) http.Handler {
|
||||||
|
return &httpWrapper{mux: mux}
|
||||||
|
}
|
||||||
|
|
||||||
type v3Mutator struct {
|
type httpWrapper struct {
|
||||||
mux *http.ServeMux
|
mux *http.ServeMux
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *v3Mutator) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
func (m *httpWrapper) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||||
|
// redirect for backward compatibilities
|
||||||
if req != nil && req.URL != nil && strings.HasPrefix(req.URL.Path, "/v3beta/") {
|
if req != nil && req.URL != nil && strings.HasPrefix(req.URL.Path, "/v3beta/") {
|
||||||
req.URL.Path = strings.Replace(req.URL.Path, "/v3beta/", "/v3/", 1)
|
req.URL.Path = strings.Replace(req.URL.Path, "/v3beta/", "/v3/", 1)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user