api

package module
v0.0.0-...-3bf0c7f Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package api is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthApi        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowApi          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupApi = fmt.Errorf("proto: unexpected end of group")
)

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.

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" validate:"min=10"`
}

func (*StringMessage) Descriptor

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

func (*StringMessage) Equal

func (this *StringMessage) Equal(that interface{}) bool

func (*StringMessage) GetValue

func (m *StringMessage) GetValue() string

func (*StringMessage) GoString

func (this *StringMessage) GoString() string

func (*StringMessage) Marshal

func (m *StringMessage) Marshal() (dAtA []byte, err error)

func (*StringMessage) MarshalTo

func (m *StringMessage) MarshalTo(dAtA []byte) (int, error)

func (*StringMessage) MarshalToSizedBuffer

func (m *StringMessage) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*StringMessage) ProtoMessage

func (*StringMessage) ProtoMessage()

func (*StringMessage) Reset

func (m *StringMessage) Reset()

func (*StringMessage) Size

func (m *StringMessage) Size() (n int)

func (*StringMessage) String

func (this *StringMessage) String() string

func (*StringMessage) Unmarshal

func (m *StringMessage) Unmarshal(dAtA []byte) error

func (*StringMessage) XXX_DiscardUnknown

func (m *StringMessage) XXX_DiscardUnknown()

func (*StringMessage) XXX_Marshal

func (m *StringMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*StringMessage) XXX_Merge

func (m *StringMessage) XXX_Merge(src proto.Message)

func (*StringMessage) XXX_Size

func (m *StringMessage) XXX_Size() int

func (*StringMessage) XXX_Unmarshal

func (m *StringMessage) XXX_Unmarshal(b []byte) error

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.

func NewYourServiceClient

func NewYourServiceClient(cc *grpc.ClientConn) YourServiceClient

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