api

package
v0.0.0-...-ae348c6 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2020 License: MIT Imports: 14 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

This section is empty.

Functions

func RegisterRestServiceHandler

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

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

func RegisterRestServiceHandlerClient

func RegisterRestServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client RestServiceClient) error

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

func RegisterRestServiceHandlerFromEndpoint

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

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

func RegisterRestServiceServer

func RegisterRestServiceServer(s *grpc.Server, srv RestServiceServer)

Types

type RestServiceClient

type RestServiceClient interface {
	Get(ctx context.Context, in *StringMessage, opts ...grpc.CallOption) (*StringMessage, error)
	Post(ctx context.Context, in *StringMessage, opts ...grpc.CallOption) (*StringMessage, error)
}

RestServiceClient is the client API for RestService service.

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

func NewRestServiceClient

func NewRestServiceClient(cc *grpc.ClientConn) RestServiceClient

type RestServiceServer

type RestServiceServer interface {
	Get(context.Context, *StringMessage) (*StringMessage, error)
	Post(context.Context, *StringMessage) (*StringMessage, error)
}

RestServiceServer is the server API for RestService service.

type StringMessage

type StringMessage struct {
	Value                string   `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

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

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 UnimplementedRestServiceServer

type UnimplementedRestServiceServer struct {
}

UnimplementedRestServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedRestServiceServer) Get

func (*UnimplementedRestServiceServer) Post

Jump to

Keyboard shortcuts

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