Documentation ¶
Overview ¶
Package api is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Constants
- Variables
- func RegisterHelloHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterHelloHandlerClient(ctx context.Context, mux *runtime.ServeMux, client HelloClient) error
- func RegisterHelloHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterHelloHandlerServer(ctx context.Context, mux *runtime.ServeMux, server HelloServer) error
- func RegisterHelloServer(s grpc.ServiceRegistrar, srv HelloServer)
- type HelloClient
- type HelloRequest
- type HelloResponse
- type HelloServer
- type UnimplementedHelloServer
- func (UnimplementedHelloServer) Name() string
- func (UnimplementedHelloServer) RegisterWithEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) error
- func (UnimplementedHelloServer) SayHello(context.Context, *HelloRequest) (*HelloResponse, error)
- func (UnimplementedHelloServer) ServiceDesc() *grpc.ServiceDesc
- type UnsafeHelloServer
Constants ¶
const (
Hello_SayHello_FullMethodName = "/helloworld.Hello/SayHello"
)
Variables ¶
var File_helloworld_proto protoreflect.FileDescriptor
var Hello_ServiceDesc = grpc.ServiceDesc{ ServiceName: "helloworld.Hello", HandlerType: (*HelloServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "SayHello", Handler: _Hello_SayHello_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "helloworld.proto", }
Hello_ServiceDesc is the grpc.ServiceDesc for Hello service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterHelloHandler ¶
RegisterHelloHandler registers the http handlers for service Hello to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterHelloHandlerClient ¶
func RegisterHelloHandlerClient(ctx context.Context, mux *runtime.ServeMux, client HelloClient) error
RegisterHelloHandlerClient registers the http handlers for service Hello to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "HelloClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "HelloClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "HelloClient" to call the correct interceptors. This client ignores the HTTP middlewares.
func RegisterHelloHandlerFromEndpoint ¶
func RegisterHelloHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterHelloHandlerFromEndpoint is same as RegisterHelloHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterHelloHandlerServer ¶
func RegisterHelloHandlerServer(ctx context.Context, mux *runtime.ServeMux, server HelloServer) error
RegisterHelloHandlerServer registers the http handlers for service Hello to "mux". UnaryRPC :call HelloServer 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 RegisterHelloHandlerFromEndpoint instead. GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
func RegisterHelloServer ¶
func RegisterHelloServer(s grpc.ServiceRegistrar, srv HelloServer)
Types ¶
type HelloClient ¶
type HelloClient interface { // Sends a hello SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloResponse, error) }
HelloClient is the client API for Hello service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
func MustNewHelloClient ¶
func MustNewHelloClient(ctx context.Context, addr string, opts ...grpc.DialOption) HelloClient
func NewHelloClient ¶
func NewHelloClient(cc grpc.ClientConnInterface) HelloClient
type HelloRequest ¶
type HelloRequest struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // contains filtered or unexported fields }
The request message containing the user's name.
func (*HelloRequest) Descriptor
deprecated
func (*HelloRequest) Descriptor() ([]byte, []int)
Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead.
func (*HelloRequest) GetName ¶
func (x *HelloRequest) GetName() string
func (*HelloRequest) ProtoMessage ¶
func (*HelloRequest) ProtoMessage()
func (*HelloRequest) ProtoReflect ¶
func (x *HelloRequest) ProtoReflect() protoreflect.Message
func (*HelloRequest) Reset ¶
func (x *HelloRequest) Reset()
func (*HelloRequest) String ¶
func (x *HelloRequest) String() string
type HelloResponse ¶
type HelloResponse struct { Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` // contains filtered or unexported fields }
The response message containing the hello
func (*HelloResponse) Descriptor
deprecated
func (*HelloResponse) Descriptor() ([]byte, []int)
Deprecated: Use HelloResponse.ProtoReflect.Descriptor instead.
func (*HelloResponse) GetMessage ¶
func (x *HelloResponse) GetMessage() string
func (*HelloResponse) ProtoMessage ¶
func (*HelloResponse) ProtoMessage()
func (*HelloResponse) ProtoReflect ¶
func (x *HelloResponse) ProtoReflect() protoreflect.Message
func (*HelloResponse) Reset ¶
func (x *HelloResponse) Reset()
func (*HelloResponse) String ¶
func (x *HelloResponse) String() string
type HelloServer ¶
type HelloServer interface { // Sends a hello SayHello(context.Context, *HelloRequest) (*HelloResponse, error) // contains filtered or unexported methods }
HelloServer is the server API for Hello service. All implementations must embed UnimplementedHelloServer for forward compatibility
type UnimplementedHelloServer ¶
type UnimplementedHelloServer struct { }
UnimplementedHelloServer must be embedded to have forward compatible implementations.
func (UnimplementedHelloServer) Name ¶
func (UnimplementedHelloServer) Name() string
func (UnimplementedHelloServer) RegisterWithEndpoint ¶
func (UnimplementedHelloServer) RegisterWithEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) error
func (UnimplementedHelloServer) SayHello ¶
func (UnimplementedHelloServer) SayHello(context.Context, *HelloRequest) (*HelloResponse, error)
func (UnimplementedHelloServer) ServiceDesc ¶
func (UnimplementedHelloServer) ServiceDesc() *grpc.ServiceDesc
type UnsafeHelloServer ¶
type UnsafeHelloServer interface {
// contains filtered or unexported methods
}
UnsafeHelloServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to HelloServer will result in compilation errors.