newGateway returns a new gateway server which translates HTTP into gRPC.
(ctx context.Context, conn *grpc.ClientConn, opts []gwruntime.ServeMuxOption)
| 17 | |
| 18 | // newGateway returns a new gateway server which translates HTTP into gRPC. |
| 19 | func 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 | |
| 39 | func dial(network, addr string) (*grpc.ClientConn, error) { |
| 40 | switch network { |