v1

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package v1 is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var File_hello_v1_hello_proto protoreflect.FileDescriptor
View Source
var Hello_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "demo.api.v1.Hello",
	HandlerType: (*HelloServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "sayHello",
			Handler:    _Hello_SayHello_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "hello/v1/hello.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

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

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.

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.

func RegisterHelloServer

func RegisterHelloServer(s grpc.ServiceRegistrar, srv HelloServer)

Types

type HelloClient

type HelloClient interface {
	SayHello(ctx context.Context, in *HelloReq, opts ...grpc.CallOption) (*HelloResp, 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 NewHelloClient

func NewHelloClient(cc grpc.ClientConnInterface) HelloClient

type HelloReq

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

func (*HelloReq) Descriptor deprecated

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

Deprecated: Use HelloReq.ProtoReflect.Descriptor instead.

func (*HelloReq) GetId

func (x *HelloReq) GetId() int64

func (*HelloReq) ProtoMessage

func (*HelloReq) ProtoMessage()

func (*HelloReq) ProtoReflect

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

func (*HelloReq) Reset

func (x *HelloReq) Reset()

func (*HelloReq) String

func (x *HelloReq) String() string

func (*HelloReq) Validate

func (m *HelloReq) Validate() error

Validate checks the field values on HelloReq 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 (*HelloReq) ValidateAll

func (m *HelloReq) ValidateAll() error

ValidateAll checks the field values on HelloReq 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 HelloReqMultiError, or nil if none found.

type HelloReqMultiError

type HelloReqMultiError []error

HelloReqMultiError is an error wrapping multiple validation errors returned by HelloReq.ValidateAll() if the designated constraints aren't met.

func (HelloReqMultiError) AllErrors

func (m HelloReqMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (HelloReqMultiError) Error

func (m HelloReqMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type HelloReqValidationError

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

HelloReqValidationError is the validation error returned by HelloReq.Validate if the designated constraints aren't met.

func (HelloReqValidationError) Cause

func (e HelloReqValidationError) Cause() error

Cause function returns cause value.

func (HelloReqValidationError) Error

func (e HelloReqValidationError) Error() string

Error satisfies the builtin error interface

func (HelloReqValidationError) ErrorName

func (e HelloReqValidationError) ErrorName() string

ErrorName returns error name.

func (HelloReqValidationError) Field

func (e HelloReqValidationError) Field() string

Field function returns field value.

func (HelloReqValidationError) Key

func (e HelloReqValidationError) Key() bool

Key function returns key value.

func (HelloReqValidationError) Reason

func (e HelloReqValidationError) Reason() string

Reason function returns reason value.

type HelloResp

type HelloResp struct {
	Id      int64  `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
	// contains filtered or unexported fields
}

func (*HelloResp) Descriptor deprecated

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

Deprecated: Use HelloResp.ProtoReflect.Descriptor instead.

func (*HelloResp) GetId

func (x *HelloResp) GetId() int64

func (*HelloResp) GetMessage

func (x *HelloResp) GetMessage() string

func (*HelloResp) ProtoMessage

func (*HelloResp) ProtoMessage()

func (*HelloResp) ProtoReflect

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

func (*HelloResp) Reset

func (x *HelloResp) Reset()

func (*HelloResp) String

func (x *HelloResp) String() string

func (*HelloResp) Validate

func (m *HelloResp) Validate() error

Validate checks the field values on HelloResp 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 (*HelloResp) ValidateAll

func (m *HelloResp) ValidateAll() error

ValidateAll checks the field values on HelloResp 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 HelloRespMultiError, or nil if none found.

type HelloRespMultiError

type HelloRespMultiError []error

HelloRespMultiError is an error wrapping multiple validation errors returned by HelloResp.ValidateAll() if the designated constraints aren't met.

func (HelloRespMultiError) AllErrors

func (m HelloRespMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (HelloRespMultiError) Error

func (m HelloRespMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type HelloRespValidationError

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

HelloRespValidationError is the validation error returned by HelloResp.Validate if the designated constraints aren't met.

func (HelloRespValidationError) Cause

func (e HelloRespValidationError) Cause() error

Cause function returns cause value.

func (HelloRespValidationError) Error

func (e HelloRespValidationError) Error() string

Error satisfies the builtin error interface

func (HelloRespValidationError) ErrorName

func (e HelloRespValidationError) ErrorName() string

ErrorName returns error name.

func (HelloRespValidationError) Field

func (e HelloRespValidationError) Field() string

Field function returns field value.

func (HelloRespValidationError) Key

Key function returns key value.

func (HelloRespValidationError) Reason

func (e HelloRespValidationError) Reason() string

Reason function returns reason value.

type HelloServer

type HelloServer interface {
	SayHello(context.Context, *HelloReq) (*HelloResp, 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) SayHello

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.

Jump to

Keyboard shortcuts

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