api

package
v0.0.0-...-21c3dfe Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

README

API

Installing Protocol buffers:

  1. go get google.golang.org/grpc
  2. go get github.com/golang/protobuf
  3. go install github.com/golang/protobuf/protoc-gen-go
  4. Install protobuf compiler via brew:
    1. Mac: brew install protobuf

Note: Don't install: google.golang.org/protobuf/cmd/protoc-gen-go. This does not support gRPC yet. See: this StackOverflow Article

Generation:

  1. To Generate go-code run:

./regenerate-sources.sh

Documentation

Overview

Package api is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const Swagger = `` /* 6548-byte string literal not displayed */

Swagger contains embedded swagger data.

Variables

View Source
var File_server_api_api_proto protoreflect.FileDescriptor

Functions

func RegisterEchoServiceHandler

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

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

func RegisterEchoServiceHandlerClient

func RegisterEchoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client EchoServiceClient) error

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

func RegisterEchoServiceHandlerFromEndpoint

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

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

func RegisterEchoServiceHandlerServer

func RegisterEchoServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server EchoServiceServer) error

RegisterEchoServiceHandlerServer registers the http handlers for service EchoService to "mux". UnaryRPC :call EchoServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.

func RegisterEchoServiceServer

func RegisterEchoServiceServer(s *grpc.Server, srv EchoServiceServer)

Types

type EchoMessage

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

An EchoMessage

func (*EchoMessage) Descriptor deprecated

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

Deprecated: Use EchoMessage.ProtoReflect.Descriptor instead.

func (*EchoMessage) GetContent

func (x *EchoMessage) GetContent() string

func (*EchoMessage) ProtoMessage

func (*EchoMessage) ProtoMessage()

func (*EchoMessage) ProtoReflect

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

func (*EchoMessage) Reset

func (x *EchoMessage) Reset()

func (*EchoMessage) String

func (x *EchoMessage) String() string

type EchoMessageCollection

type EchoMessageCollection struct {
	EchoMessages []*EchoMessage `protobuf:"bytes,1,rep,name=echo_messages,json=echoMessages,proto3" json:"echo_messages,omitempty"`
	// contains filtered or unexported fields
}

EchoMessageCollection is a collection of EchoMessages

func (*EchoMessageCollection) Descriptor deprecated

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

Deprecated: Use EchoMessageCollection.ProtoReflect.Descriptor instead.

func (*EchoMessageCollection) GetEchoMessages

func (x *EchoMessageCollection) GetEchoMessages() []*EchoMessage

func (*EchoMessageCollection) ProtoMessage

func (*EchoMessageCollection) ProtoMessage()

func (*EchoMessageCollection) ProtoReflect

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

func (*EchoMessageCollection) Reset

func (x *EchoMessageCollection) Reset()

func (*EchoMessageCollection) String

func (x *EchoMessageCollection) String() string

type EchoRequest

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

EchoRequest contains a request for an echo-message.

func (*EchoRequest) Descriptor deprecated

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

Deprecated: Use EchoRequest.ProtoReflect.Descriptor instead.

func (*EchoRequest) GetId

func (x *EchoRequest) GetId() string

func (*EchoRequest) ProtoMessage

func (*EchoRequest) ProtoMessage()

func (*EchoRequest) ProtoReflect

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

func (*EchoRequest) Reset

func (x *EchoRequest) Reset()

func (*EchoRequest) String

func (x *EchoRequest) String() string

type EchoServiceClient

type EchoServiceClient interface {
	// GetEchoMessage gets a single EchoMessage
	GetEchoMessage(ctx context.Context, in *EchoRequest, opts ...grpc.CallOption) (*EchoMessage, error)
	// ListEchoMessage lists all the EchoMessages.
	ListEchoMessages(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (*EchoMessageCollection, error)
}

EchoServiceClient is the client API for EchoService service.

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

type EchoServiceServer

type EchoServiceServer interface {
	// GetEchoMessage gets a single EchoMessage
	GetEchoMessage(context.Context, *EchoRequest) (*EchoMessage, error)
	// ListEchoMessage lists all the EchoMessages.
	ListEchoMessages(context.Context, *EmptyRequest) (*EchoMessageCollection, error)
}

EchoServiceServer is the server API for EchoService service.

type EmptyRequest

type EmptyRequest struct {
	// contains filtered or unexported fields
}

EmptyRequest is contains no content.

func (*EmptyRequest) Descriptor deprecated

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

Deprecated: Use EmptyRequest.ProtoReflect.Descriptor instead.

func (*EmptyRequest) ProtoMessage

func (*EmptyRequest) ProtoMessage()

func (*EmptyRequest) ProtoReflect

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

func (*EmptyRequest) Reset

func (x *EmptyRequest) Reset()

func (*EmptyRequest) String

func (x *EmptyRequest) String() string

type UnimplementedEchoServiceServer

type UnimplementedEchoServiceServer struct {
}

UnimplementedEchoServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedEchoServiceServer) GetEchoMessage

func (*UnimplementedEchoServiceServer) ListEchoMessages

Jump to

Keyboard shortcuts

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