api

package
v0.0.0-...-f47a602 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: BSD-2-Clause Imports: 17 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 File_proto_api_greeting_proto protoreflect.FileDescriptor
View Source
var GreetingService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "api.GreetingService",
	HandlerType: (*GreetingServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Error",
			Handler:    _GreetingService_Error_Handler,
		},
		{
			MethodName: "GetHello",
			Handler:    _GreetingService_GetHello_Handler,
		},
		{
			MethodName: "PostHello",
			Handler:    _GreetingService_PostHello_Handler,
		},
		{
			MethodName: "DeleteHello",
			Handler:    _GreetingService_DeleteHello_Handler,
		},
		{
			MethodName: "PutHello",
			Handler:    _GreetingService_PutHello_Handler,
		},
		{
			MethodName: "PatchHello",
			Handler:    _GreetingService_PatchHello_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "proto/api/greeting.proto",
}

GreetingService_ServiceDesc is the grpc.ServiceDesc for GreetingService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterGreetingServiceHandler

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

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

func RegisterGreetingServiceHandlerClient

func RegisterGreetingServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client GreetingServiceClient) error

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

func RegisterGreetingServiceHandlerFromEndpoint

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

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

func RegisterGreetingServiceHandlerServer

func RegisterGreetingServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server GreetingServiceServer) error

RegisterGreetingServiceHandlerServer registers the http handlers for service GreetingService to "mux". UnaryRPC :call GreetingServiceServer 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 RegisterGreetingServiceHandlerFromEndpoint instead.

func RegisterGreetingServiceServer

func RegisterGreetingServiceServer(s grpc.ServiceRegistrar, srv GreetingServiceServer)

Types

type GreetingServiceClient

type GreetingServiceClient interface {
	Error(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error)
	GetHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloResponse, error)
	PostHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloResponse, error)
	DeleteHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloResponse, error)
	PutHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloResponse, error)
	PatchHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloResponse, error)
}

GreetingServiceClient is the client API for GreetingService 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.

type GreetingServiceServer

type GreetingServiceServer interface {
	Error(context.Context, *emptypb.Empty) (*emptypb.Empty, error)
	GetHello(context.Context, *HelloRequest) (*HelloResponse, error)
	PostHello(context.Context, *HelloRequest) (*HelloResponse, error)
	DeleteHello(context.Context, *HelloRequest) (*HelloResponse, error)
	PutHello(context.Context, *HelloRequest) (*HelloResponse, error)
	PatchHello(context.Context, *HelloRequest) (*HelloResponse, error)
	// contains filtered or unexported methods
}

GreetingServiceServer is the server API for GreetingService service. All implementations must embed UnimplementedGreetingServiceServer for forward compatibility

type HelloRequest

type HelloRequest struct {
	Title  string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
	Name   string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	Method string `protobuf:"bytes,3,opt,name=method,proto3" json:"method,omitempty"`
	// contains filtered or unexported fields
}

func (*HelloRequest) Descriptor deprecated

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

Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead.

func (*HelloRequest) GetMethod

func (x *HelloRequest) GetMethod() string

func (*HelloRequest) GetName

func (x *HelloRequest) GetName() string

func (*HelloRequest) GetTitle

func (x *HelloRequest) GetTitle() 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"`
	Method  string `protobuf:"bytes,2,opt,name=method,proto3" json:"method,omitempty"`
	// contains filtered or unexported fields
}

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) GetMethod

func (x *HelloResponse) GetMethod() 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 UnimplementedGreetingServiceServer

type UnimplementedGreetingServiceServer struct {
}

UnimplementedGreetingServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedGreetingServiceServer) DeleteHello

func (UnimplementedGreetingServiceServer) Error

func (UnimplementedGreetingServiceServer) GetHello

func (UnimplementedGreetingServiceServer) PatchHello

func (UnimplementedGreetingServiceServer) PostHello

func (UnimplementedGreetingServiceServer) PutHello

type UnsafeGreetingServiceServer

type UnsafeGreetingServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeGreetingServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to GreetingServiceServer will result in compilation errors.

Jump to

Keyboard shortcuts

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