Documentation ¶
Overview ¶
Package grpc_gateway_example is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Constants
- Variables
- func RegisterExampleHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterExampleHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ExampleClient) error
- func RegisterExampleHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterExampleHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ExampleServer) error
- func RegisterExampleServer(s grpc.ServiceRegistrar, srv ExampleServer)
- type ExampleClient
- type ExampleServer
- type HelloRequest
- func (*HelloRequest) Descriptor() ([]byte, []int)deprecated
- func (x *HelloRequest) GetEmail() string
- func (x *HelloRequest) GetName() string
- func (*HelloRequest) ProtoMessage()
- func (x *HelloRequest) ProtoReflect() protoreflect.Message
- func (x *HelloRequest) Reset()
- func (x *HelloRequest) String() string
- func (m *HelloRequest) Validate() error
- func (m *HelloRequest) ValidateAll() error
- type HelloRequestMultiError
- type HelloRequestValidationError
- func (e HelloRequestValidationError) Cause() error
- func (e HelloRequestValidationError) Error() string
- func (e HelloRequestValidationError) ErrorName() string
- func (e HelloRequestValidationError) Field() string
- func (e HelloRequestValidationError) Key() bool
- func (e HelloRequestValidationError) Reason() string
- type HelloResponse
- func (*HelloResponse) Descriptor() ([]byte, []int)deprecated
- func (x *HelloResponse) GetMessage() string
- func (*HelloResponse) ProtoMessage()
- func (x *HelloResponse) ProtoReflect() protoreflect.Message
- func (x *HelloResponse) Reset()
- func (x *HelloResponse) String() string
- func (m *HelloResponse) Validate() error
- func (m *HelloResponse) ValidateAll() error
- type HelloResponseMultiError
- type HelloResponseValidationError
- func (e HelloResponseValidationError) Cause() error
- func (e HelloResponseValidationError) Error() string
- func (e HelloResponseValidationError) ErrorName() string
- func (e HelloResponseValidationError) Field() string
- func (e HelloResponseValidationError) Key() bool
- func (e HelloResponseValidationError) Reason() string
- type UnimplementedExampleServer
- type UnsafeExampleServer
Constants ¶
const (
Example_Hello_FullMethodName = "/example.Example/Hello"
)
Variables ¶
var Example_ServiceDesc = grpc.ServiceDesc{ ServiceName: "example.Example", HandlerType: (*ExampleServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Hello", Handler: _Example_Hello_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "example.proto", }
Example_ServiceDesc is the grpc.ServiceDesc for Example service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
var File_example_proto protoreflect.FileDescriptor
Functions ¶
func RegisterExampleHandler ¶
func RegisterExampleHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
RegisterExampleHandler registers the http handlers for service Example to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterExampleHandlerClient ¶
func RegisterExampleHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ExampleClient) error
RegisterExampleHandlerClient registers the http handlers for service Example to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ExampleClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ExampleClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "ExampleClient" to call the correct interceptors.
func RegisterExampleHandlerFromEndpoint ¶
func RegisterExampleHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterExampleHandlerFromEndpoint is same as RegisterExampleHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterExampleHandlerServer ¶
func RegisterExampleHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ExampleServer) error
RegisterExampleHandlerServer registers the http handlers for service Example to "mux". UnaryRPC :call ExampleServer 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 RegisterExampleHandlerFromEndpoint instead.
func RegisterExampleServer ¶
func RegisterExampleServer(s grpc.ServiceRegistrar, srv ExampleServer)
Types ¶
type ExampleClient ¶
type ExampleClient interface {
Hello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloResponse, error)
}
ExampleClient is the client API for Example 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 NewExampleClient ¶
func NewExampleClient(cc grpc.ClientConnInterface) ExampleClient
type ExampleServer ¶
type ExampleServer interface {
Hello(context.Context, *HelloRequest) (*HelloResponse, error)
}
ExampleServer is the server API for Example service. All implementations should embed UnimplementedExampleServer for forward compatibility
type HelloRequest ¶
type HelloRequest struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Email *string `protobuf:"bytes,2,opt,name=email,proto3,oneof" json:"email,omitempty"` // contains filtered or unexported fields }
func (*HelloRequest) Descriptor
deprecated
func (*HelloRequest) Descriptor() ([]byte, []int)
Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead.
func (*HelloRequest) GetEmail ¶
func (x *HelloRequest) GetEmail() string
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
func (*HelloRequest) Validate ¶
func (m *HelloRequest) Validate() error
Validate checks the field values on HelloRequest with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*HelloRequest) ValidateAll ¶
func (m *HelloRequest) ValidateAll() error
ValidateAll checks the field values on HelloRequest with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in HelloRequestMultiError, or nil if none found.
type HelloRequestMultiError ¶
type HelloRequestMultiError []error
HelloRequestMultiError is an error wrapping multiple validation errors returned by HelloRequest.ValidateAll() if the designated constraints aren't met.
func (HelloRequestMultiError) AllErrors ¶
func (m HelloRequestMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (HelloRequestMultiError) Error ¶
func (m HelloRequestMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type HelloRequestValidationError ¶
type HelloRequestValidationError struct {
// contains filtered or unexported fields
}
HelloRequestValidationError is the validation error returned by HelloRequest.Validate if the designated constraints aren't met.
func (HelloRequestValidationError) Cause ¶
func (e HelloRequestValidationError) Cause() error
Cause function returns cause value.
func (HelloRequestValidationError) Error ¶
func (e HelloRequestValidationError) Error() string
Error satisfies the builtin error interface
func (HelloRequestValidationError) ErrorName ¶
func (e HelloRequestValidationError) ErrorName() string
ErrorName returns error name.
func (HelloRequestValidationError) Field ¶
func (e HelloRequestValidationError) Field() string
Field function returns field value.
func (HelloRequestValidationError) Key ¶
func (e HelloRequestValidationError) Key() bool
Key function returns key value.
func (HelloRequestValidationError) Reason ¶
func (e HelloRequestValidationError) Reason() string
Reason function returns reason value.
type HelloResponse ¶
type HelloResponse struct { Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,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) 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
func (*HelloResponse) Validate ¶
func (m *HelloResponse) Validate() error
Validate checks the field values on HelloResponse with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*HelloResponse) ValidateAll ¶
func (m *HelloResponse) ValidateAll() error
ValidateAll checks the field values on HelloResponse with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in HelloResponseMultiError, or nil if none found.
type HelloResponseMultiError ¶
type HelloResponseMultiError []error
HelloResponseMultiError is an error wrapping multiple validation errors returned by HelloResponse.ValidateAll() if the designated constraints aren't met.
func (HelloResponseMultiError) AllErrors ¶
func (m HelloResponseMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (HelloResponseMultiError) Error ¶
func (m HelloResponseMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type HelloResponseValidationError ¶
type HelloResponseValidationError struct {
// contains filtered or unexported fields
}
HelloResponseValidationError is the validation error returned by HelloResponse.Validate if the designated constraints aren't met.
func (HelloResponseValidationError) Cause ¶
func (e HelloResponseValidationError) Cause() error
Cause function returns cause value.
func (HelloResponseValidationError) Error ¶
func (e HelloResponseValidationError) Error() string
Error satisfies the builtin error interface
func (HelloResponseValidationError) ErrorName ¶
func (e HelloResponseValidationError) ErrorName() string
ErrorName returns error name.
func (HelloResponseValidationError) Field ¶
func (e HelloResponseValidationError) Field() string
Field function returns field value.
func (HelloResponseValidationError) Key ¶
func (e HelloResponseValidationError) Key() bool
Key function returns key value.
func (HelloResponseValidationError) Reason ¶
func (e HelloResponseValidationError) Reason() string
Reason function returns reason value.
type UnimplementedExampleServer ¶
type UnimplementedExampleServer struct { }
UnimplementedExampleServer should be embedded to have forward compatible implementations.
func (UnimplementedExampleServer) Hello ¶
func (UnimplementedExampleServer) Hello(context.Context, *HelloRequest) (*HelloResponse, error)
type UnsafeExampleServer ¶
type UnsafeExampleServer interface {
// contains filtered or unexported methods
}
UnsafeExampleServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ExampleServer will result in compilation errors.