|
|
@@ -122,6 +122,11 @@ func (sctx *serveCtx) serve(s *etcdserver.EtcdServer, tlscfg *tls.Config, handle
|
|
|
// grpcHandlerFunc returns an http.Handler that delegates to grpcServer on incoming gRPC
|
|
|
// connections or otherHandler otherwise. Copied from cockroachdb.
|
|
|
func grpcHandlerFunc(grpcServer *grpc.Server, otherHandler http.Handler) http.Handler {
|
|
|
+ if otherHandler == nil {
|
|
|
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
+ grpcServer.ServeHTTP(w, r)
|
|
|
+ })
|
|
|
+ }
|
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
if r.ProtoMajor == 2 && strings.Contains(r.Header.Get("Content-Type"), "application/grpc") {
|
|
|
grpcServer.ServeHTTP(w, r)
|
|
|
@@ -181,7 +186,9 @@ func (sctx *serveCtx) createMux(gwmux *gw.ServeMux, handler http.Handler) *http.
|
|
|
}
|
|
|
|
|
|
httpmux.Handle("/v3alpha/", gwmux)
|
|
|
- httpmux.Handle("/", handler)
|
|
|
+ if handler != nil {
|
|
|
+ httpmux.Handle("/", handler)
|
|
|
+ }
|
|
|
return httpmux
|
|
|
}
|
|
|
|