Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions runtime/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ go_library(
"//internal/httprule",
"//utilities",
"@org_golang_google_genproto_googleapis_api//httpbody",
"@org_golang_google_grpc//:grpc",
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//grpclog",
"@org_golang_google_grpc//health/grpc_health_v1",
Expand Down
16 changes: 12 additions & 4 deletions runtime/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"

"github.com/grpc-ecosystem/grpc-gateway/v2/internal/httprule"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/health/grpc_health_v1"
Expand Down Expand Up @@ -281,12 +282,19 @@ func WithHealthEndpointAt(healthCheckClient grpc_health_v1.HealthClient, endpoin
http.MethodGet, endpointPath, func(w http.ResponseWriter, r *http.Request, _ map[string]string,
) {
_, outboundMarshaler := MarshalerForRequest(s, r)
annotatedContext, err := AnnotateContext(r.Context(), s, r, grpc_health_v1.Health_Check_FullMethodName, WithHTTPPathPattern(endpointPath))
if err != nil {
s.errorHandler(r.Context(), s, outboundMarshaler, w, r, err)
return
}

resp, err := healthCheckClient.Check(r.Context(), &grpc_health_v1.HealthCheckRequest{
var md ServerMetadata
resp, err := healthCheckClient.Check(annotatedContext, &grpc_health_v1.HealthCheckRequest{
Service: r.URL.Query().Get("service"),
})
}, grpc.Header(&md.HeaderMD), grpc.Trailer(&md.TrailerMD))
annotatedContext = NewServerMetadataContext(annotatedContext, md)
if err != nil {
s.errorHandler(r.Context(), s, outboundMarshaler, w, r, err)
s.errorHandler(annotatedContext, s, outboundMarshaler, w, r, err)
return
}

Expand All @@ -300,7 +308,7 @@ func WithHealthEndpointAt(healthCheckClient grpc_health_v1.HealthClient, endpoin
err = status.Error(codes.NotFound, resp.String())
}

s.errorHandler(r.Context(), s, outboundMarshaler, w, r, err)
s.errorHandler(annotatedContext, s, outboundMarshaler, w, r, err)
return
}

Expand Down
Loading