MCPcopy
hub / github.com/grpc-ecosystem/grpc-gateway / newGateway

Function newGateway

examples/internal/gateway/gateway.go:19–37  ·  view source on GitHub ↗

newGateway returns a new gateway server which translates HTTP into gRPC.

(ctx context.Context, conn *grpc.ClientConn, opts []gwruntime.ServeMuxOption)

Source from the content-addressed store, hash-verified

17
18// newGateway returns a new gateway server which translates HTTP into gRPC.
19func newGateway(ctx context.Context, conn *grpc.ClientConn, opts []gwruntime.ServeMuxOption) (http.Handler, error) {
20 mux := gwruntime.NewServeMux(opts...)
21
22 for _, f := range []func(context.Context, *gwruntime.ServeMux, *grpc.ClientConn) error{
23 examplepb.RegisterEchoServiceHandler,
24 standalone.RegisterUnannotatedEchoServiceHandler,
25 examplepb.RegisterStreamServiceHandler,
26 examplepb.RegisterABitOfEverythingServiceHandler,
27 examplepb.RegisterFlowCombinationHandler,
28 examplepb.RegisterExcessBodyServiceHandler,
29 examplepb.RegisterNonStandardServiceHandler,
30 examplepb.RegisterResponseBodyServiceHandler,
31 } {
32 if err := f(ctx, mux, conn); err != nil {
33 return nil, err
34 }
35 }
36 return mux, nil
37}
38
39func dial(network, addr string) (*grpc.ClientConn, error) {
40 switch network {

Callers 1

RunFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected