httpgrpc

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLength        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflow          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroup = fmt.Errorf("proto: unexpected end of group")
)
View Source
var File_util_httpgrpc_httpgrpc_proto protoreflect.FileDescriptor
View Source
var HTTP_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "httpgrpc.HTTP",
	HandlerType: (*HTTPServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Handle",
			Handler:    _HTTP_Handle_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "util/httpgrpc/httpgrpc.proto",
}

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

Functions

func ErrorFromHTTPResponse

func ErrorFromHTTPResponse(resp *HTTPResponse) error

ErrorFromHTTPResponse converts an HTTP response into a grpc error

func Errorf

func Errorf(code int, tmpl string, args ...interface{}) error

Errorf returns a HTTP gRPC error than is correctly forwarded over gRPC, and can eventually be converted back to a HTTP response with HTTPResponseFromError.

func RegisterHTTPServer

func RegisterHTTPServer(s grpc.ServiceRegistrar, srv HTTPServer)

Types

type HTTPClient

type HTTPClient interface {
	Handle(ctx context.Context, in *HTTPRequest, opts ...grpc.CallOption) (*HTTPResponse, error)
}

HTTPClient is the client API for HTTP 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 NewHTTPClient

func NewHTTPClient(cc grpc.ClientConnInterface) HTTPClient

type HTTPRequest

type HTTPRequest struct {
	Method  string    `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"`
	Url     string    `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"`
	Headers []*Header `protobuf:"bytes,3,rep,name=headers,proto3" json:"headers,omitempty"`
	Body    []byte    `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"`
	// contains filtered or unexported fields
}

func (*HTTPRequest) Descriptor deprecated

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

Deprecated: Use HTTPRequest.ProtoReflect.Descriptor instead.

func (*HTTPRequest) GetBody

func (x *HTTPRequest) GetBody() []byte

func (*HTTPRequest) GetHeaders

func (x *HTTPRequest) GetHeaders() []*Header

func (*HTTPRequest) GetMethod

func (x *HTTPRequest) GetMethod() string

func (*HTTPRequest) GetUrl

func (x *HTTPRequest) GetUrl() string

func (*HTTPRequest) MarshalToSizedBufferVT

func (m *HTTPRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*HTTPRequest) MarshalToVT

func (m *HTTPRequest) MarshalToVT(dAtA []byte) (int, error)

func (*HTTPRequest) MarshalVT

func (m *HTTPRequest) MarshalVT() (dAtA []byte, err error)

func (*HTTPRequest) ProtoMessage

func (*HTTPRequest) ProtoMessage()

func (*HTTPRequest) ProtoReflect

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

func (*HTTPRequest) Reset

func (x *HTTPRequest) Reset()

func (*HTTPRequest) SizeVT

func (m *HTTPRequest) SizeVT() (n int)

func (*HTTPRequest) String

func (x *HTTPRequest) String() string

func (*HTTPRequest) UnmarshalVT

func (m *HTTPRequest) UnmarshalVT(dAtA []byte) error

type HTTPResponse

type HTTPResponse struct {
	Code    int32     `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"`
	Headers []*Header `protobuf:"bytes,2,rep,name=headers,proto3" json:"headers,omitempty"`
	Body    []byte    `protobuf:"bytes,3,opt,name=body,proto3" json:"body,omitempty"`
	// contains filtered or unexported fields
}

func HTTPResponseFromError

func HTTPResponseFromError(err error) (*HTTPResponse, bool)

HTTPResponseFromError converts a grpc error into an HTTP response

func (*HTTPResponse) Descriptor deprecated

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

Deprecated: Use HTTPResponse.ProtoReflect.Descriptor instead.

func (*HTTPResponse) GetBody

func (x *HTTPResponse) GetBody() []byte

func (*HTTPResponse) GetCode

func (x *HTTPResponse) GetCode() int32

func (*HTTPResponse) GetHeaders

func (x *HTTPResponse) GetHeaders() []*Header

func (*HTTPResponse) MarshalToSizedBufferVT

func (m *HTTPResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*HTTPResponse) MarshalToVT

func (m *HTTPResponse) MarshalToVT(dAtA []byte) (int, error)

func (*HTTPResponse) MarshalVT

func (m *HTTPResponse) MarshalVT() (dAtA []byte, err error)

func (*HTTPResponse) ProtoMessage

func (*HTTPResponse) ProtoMessage()

func (*HTTPResponse) ProtoReflect

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

func (*HTTPResponse) Reset

func (x *HTTPResponse) Reset()

func (*HTTPResponse) SizeVT

func (m *HTTPResponse) SizeVT() (n int)

func (*HTTPResponse) String

func (x *HTTPResponse) String() string

func (*HTTPResponse) UnmarshalVT

func (m *HTTPResponse) UnmarshalVT(dAtA []byte) error

type HTTPServer

type HTTPServer interface {
	Handle(context.Context, *HTTPRequest) (*HTTPResponse, error)
	// contains filtered or unexported methods
}

HTTPServer is the server API for HTTP service. All implementations must embed UnimplementedHTTPServer for forward compatibility

type Header struct {
	Key    string   `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	Values []string `protobuf:"bytes,2,rep,name=values,proto3" json:"values,omitempty"`
	// contains filtered or unexported fields
}

func (*Header) Descriptor deprecated

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

Deprecated: Use Header.ProtoReflect.Descriptor instead.

func (*Header) GetKey

func (x *Header) GetKey() string

func (*Header) GetValues

func (x *Header) GetValues() []string

func (*Header) MarshalToSizedBufferVT

func (m *Header) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Header) MarshalToVT

func (m *Header) MarshalToVT(dAtA []byte) (int, error)

func (*Header) MarshalVT

func (m *Header) MarshalVT() (dAtA []byte, err error)

func (*Header) ProtoMessage

func (*Header) ProtoMessage()

func (*Header) ProtoReflect

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

func (*Header) Reset

func (x *Header) Reset()

func (*Header) SizeVT

func (m *Header) SizeVT() (n int)

func (*Header) String

func (x *Header) String() string

func (*Header) UnmarshalVT

func (m *Header) UnmarshalVT(dAtA []byte) error

type UnimplementedHTTPServer

type UnimplementedHTTPServer struct {
}

UnimplementedHTTPServer must be embedded to have forward compatible implementations.

func (UnimplementedHTTPServer) Handle

type UnsafeHTTPServer

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

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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