mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 13:11:49 +00:00
grpc: put grpcwebui behind environment variable (#56314)
This commit is contained in:
parent
23ad498c62
commit
3cb0b12b11
@ -6,12 +6,15 @@ import (
|
||||
|
||||
"github.com/fullstorydev/grpcui/standalone"
|
||||
"github.com/sourcegraph/log"
|
||||
"github.com/sourcegraph/sourcegraph/internal/env"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/internal/grpc/defaults"
|
||||
"github.com/sourcegraph/sourcegraph/lib/errors"
|
||||
)
|
||||
|
||||
var envEnableGRPCWebUI = env.MustGetBool("GRPC_WEB_UI_ENABLED", false, "Enable the gRPC Web UI to debug and explore gRPC services")
|
||||
|
||||
const gRPCWebUIPath = "/debug/grpcui"
|
||||
|
||||
// NewGRPCWebUIEndpoint returns a new Endpoint that serves a gRPC Web UI instance
|
||||
@ -50,6 +53,11 @@ type grpcHandler struct {
|
||||
}
|
||||
|
||||
func (g *grpcHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if !envEnableGRPCWebUI {
|
||||
http.Error(w, "gRPC Web UI is disabled", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
ctx := r.Context()
|
||||
|
||||
cc, err := grpc.DialContext(ctx, g.target, g.dialOpts...)
|
||||
|
||||
@ -119,6 +119,9 @@ env:
|
||||
# OTEL_EXPORTER_OTLP_ENDPOINT: http://127.0.0.1:4318
|
||||
# OTEL_EXPORTER_OTLP_PROTOCOL: http/json
|
||||
|
||||
# Enable gRPC Web UI for debugging
|
||||
GRPC_WEB_UI_ENABLED: "true"
|
||||
|
||||
# Enable full protobuf message logging when an internal error occurred
|
||||
SRC_GRPC_INTERNAL_ERROR_LOGGING_LOG_PROTOBUF_MESSAGES_ENABLED: "true"
|
||||
SRC_GRPC_INTERNAL_ERROR_LOGGING_LOG_PROTOBUF_MESSAGES_JSON_TRUNCATION_SIZE_BYTES: "1KB"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user