example

package
v0.0.0-...-1991fdf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package example is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var File_example_proto protoreflect.FileDescriptor

Functions

func RegisterYourServiceHandler

func RegisterYourServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterYourServiceHandler registers the http handlers for service YourService to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterYourServiceHandlerClient

func RegisterYourServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client YourServiceClient) error

RegisterYourServiceHandlerClient registers the http handlers for service YourService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "YourServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "YourServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "YourServiceClient" to call the correct interceptors.

func RegisterYourServiceHandlerFromEndpoint

func RegisterYourServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterYourServiceHandlerFromEndpoint is same as RegisterYourServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterYourServiceHandlerServer

func RegisterYourServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server YourServiceServer) error

RegisterYourServiceHandlerServer registers the http handlers for service YourService to "mux". UnaryRPC :call YourServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterYourServiceHandlerFromEndpoint instead.

func RegisterYourServiceServer

func RegisterYourServiceServer(s *grpc.Server, srv YourServiceServer)

Types

type StringMessage

type StringMessage struct {
	Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

func (*StringMessage) Descriptor deprecated

func (*StringMessage) Descriptor() ([]byte, []int)

Deprecated: Use StringMessage.ProtoReflect.Descriptor instead.

func (*StringMessage) GetValue

func (x *StringMessage) GetValue() string

func (*StringMessage) ProtoMessage

func (*StringMessage) ProtoMessage()

func (*StringMessage) ProtoReflect

func (x *StringMessage) ProtoReflect() protoreflect.Message

func (*StringMessage) Reset

func (x *StringMessage) Reset()

func (*StringMessage) String

func (x *StringMessage) String() string

type UnimplementedYourServiceServer

type UnimplementedYourServiceServer struct {
}

UnimplementedYourServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedYourServiceServer) Echo

type YourServiceClient

type YourServiceClient interface {
	Echo(ctx context.Context, in *StringMessage, opts ...grpc.CallOption) (*StringMessage, error)
}

YourServiceClient is the client API for YourService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

type YourServiceServer

type YourServiceServer interface {
	Echo(context.Context, *StringMessage) (*StringMessage, error)
}

YourServiceServer is the server API for YourService service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL