v1

package
v0.0.29 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package v1 is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	MyGreeter_SayHello_FullMethodName = "/MyGreeter/SayHello"
)

Variables

View Source
var MyGreeter_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "MyGreeter",
	HandlerType: (*MyGreeterServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "SayHello",
			Handler:    _MyGreeter_SayHello_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "api.proto",
}

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

Functions

func RegisterMyGreeterHandler

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

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

func RegisterMyGreeterHandlerClient

func RegisterMyGreeterHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MyGreeterClient) error

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

func RegisterMyGreeterHandlerFromEndpoint

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

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

func RegisterMyGreeterHandlerServer

func RegisterMyGreeterHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MyGreeterServer) error

RegisterMyGreeterHandlerServer registers the http handlers for service MyGreeter to "mux". UnaryRPC :call MyGreeterServer 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 RegisterMyGreeterHandlerFromEndpoint instead.

func RegisterMyGreeterServer

func RegisterMyGreeterServer(s grpc.ServiceRegistrar, srv MyGreeterServer)

Types

type Address

type Address struct {
	City    string `protobuf:"bytes,1,opt,name=city,proto3" json:"city,omitempty"`        // The city name
	State   string `protobuf:"bytes,2,opt,name=state,proto3" json:"state,omitempty"`      // The state name
	Zipcode int32  `protobuf:"varint,3,opt,name=zipcode,proto3" json:"zipcode,omitempty"` // The zip code
	Street  string `protobuf:"bytes,4,opt,name=street,proto3" json:"street,omitempty"`    // The street name
	// contains filtered or unexported fields
}

func (*Address) Descriptor deprecated

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

Deprecated: Use Address.ProtoReflect.Descriptor instead.

func (*Address) GetCity

func (x *Address) GetCity() string

func (*Address) GetState

func (x *Address) GetState() string

func (*Address) GetStreet

func (x *Address) GetStreet() string

func (*Address) GetZipcode

func (x *Address) GetZipcode() int32

func (*Address) ProtoMessage

func (*Address) ProtoMessage()

func (*Address) ProtoReflect

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

func (*Address) Reset

func (x *Address) Reset()

func (*Address) String

func (x *Address) String() string

type HelloReply

type HelloReply struct {
	Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
	// contains filtered or unexported fields
}

func (*HelloReply) Descriptor deprecated

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

Deprecated: Use HelloReply.ProtoReflect.Descriptor instead.

func (*HelloReply) GetMessage

func (x *HelloReply) GetMessage() string

func (*HelloReply) ProtoMessage

func (*HelloReply) ProtoMessage()

func (*HelloReply) ProtoReflect

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

func (*HelloReply) Reset

func (x *HelloReply) Reset()

func (*HelloReply) String

func (x *HelloReply) String() string

type HelloRequest

type HelloRequest struct {
	Name    string   `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Age     int32    `protobuf:"varint,2,opt,name=age,proto3" json:"age,omitempty"`
	Email   string   `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
	Address *Address `protobuf:"bytes,4,opt,name=address,proto3,oneof" json:"address,omitempty"`
	// contains filtered or unexported fields
}

func (*HelloRequest) Descriptor deprecated

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

Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead.

func (*HelloRequest) GetAddress

func (x *HelloRequest) GetAddress() *Address

func (*HelloRequest) GetAge

func (x *HelloRequest) GetAge() int32

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

type MyGreeterClient

type MyGreeterClient interface {
	// Sends a greeting
	SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error)
}

MyGreeterClient is the client API for MyGreeter 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 NewMyGreeterClient

func NewMyGreeterClient(cc grpc.ClientConnInterface) MyGreeterClient

type MyGreeterServer

type MyGreeterServer interface {
	// Sends a greeting
	SayHello(context.Context, *HelloRequest) (*HelloReply, error)
	// contains filtered or unexported methods
}

MyGreeterServer is the server API for MyGreeter service. All implementations must embed UnimplementedMyGreeterServer for forward compatibility.

type UnimplementedMyGreeterServer

type UnimplementedMyGreeterServer struct{}

UnimplementedMyGreeterServer must be embedded to have forward compatible implementations.

NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.

func (UnimplementedMyGreeterServer) SayHello

type UnsafeMyGreeterServer

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

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

Jump to

Keyboard shortcuts

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