example

package
v0.0.0-...-4a656d5 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: CC0-1.0 Imports: 13 Imported by: 0

README

grpc-gateway-example

Just write my_service.proto and make to generate

  • grpc based Go files.
  • grpc-gateway based reverse proxy.
  • swagger definition.
  • server based on swagger definition
  • client based on swagger definition

Documentation

Overview

Package example is a generated protocol buffer package.

It is generated from these files:

my_service.proto

It has these top-level messages:

StringMessage

Package example is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

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

RegisterYourServiceHandler 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 RegisterYourServiceServer

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

Types

type StringMessage

type StringMessage struct {
	Value string `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"`
}

func (*StringMessage) Descriptor

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

func (*StringMessage) GetValue

func (m *StringMessage) GetValue() string

func (*StringMessage) ProtoMessage

func (*StringMessage) ProtoMessage()

func (*StringMessage) Reset

func (m *StringMessage) Reset()

func (*StringMessage) String

func (m *StringMessage) String() string

type YourServiceClient

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

func NewYourServiceClient

func NewYourServiceClient(cc *grpc.ClientConn) YourServiceClient

type YourServiceServer

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

Directories

Path Synopsis
cmd
Package restapi my_service.proto
Package restapi my_service.proto

Jump to

Keyboard shortcuts

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