Skip to content

grpcreflect

Build GoDoc

connectrpc.com/grpcreflect/v2 adds support for gRPC's server reflection API to servers built with Connect. With server reflection enabled, ad-hoc debugging tools can call your gRPC-compatible handlers and print the responses without a copy of the schema.

The exposed reflection API is wire compatible with Google's gRPC implementations, so it works with grpcurl, grpcui, and many other tools.

For more on Connect, see the announcement blog post, the documentation on connectrpc.com (especially the Getting Started guide for Go), the Connect repo, or the demo service.

Example

package main

import (
  "log"
  "net/http"

  "connectrpc.com/connect/v2"
  "connectrpc.com/connect/v2/connecthttp"
  "connectrpc.com/grpcreflect/v2"
)

func main() {
  server := connect.NewServer()
  // Register your Connect services on the server, then register reflection.
  // By default, reflection describes the services registered on the server,
  // and serves both the v1 and v1alpha versions of the reflection API.
  grpcreflect.Register(server)
  mux := http.NewServeMux()
  connecthttp.Mount(mux, server)
  p := new(http.Protocols)
  p.SetHTTP1(true)
  // The reflection API requires bidirectional streaming, so it's only served
  // over HTTP/2. Supporting HTTP/2 without TLS is convenient for gRPC tools.
  p.SetUnencryptedHTTP2(true)
  s := &http.Server{
    Addr:      ":8080",
    Handler:   mux,
    Protocols: p,
  }
  if err := s.ListenAndServe(); err != nil {
    log.Fatalf("listen failed: %v", err)
  }
}

Status: Unstable

This module is unstable while connect-go v2 is in alpha. Expect breaking changes as we iterate toward a stable v2 release.

It supports:

Legal

Offered under the Apache 2 license.

About

gRPC-compatible server reflection for any net/http server.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

113 stars

Watchers

9 watching

Forks

Releases

Used by

Contributors

Languages