gateway

package
v0.0.0-...-02c9ee4 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package gateway is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Package gateway is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var Group_name = map[int32]string{
	0: "USER",
	1: "ADMIN",
	2: "DEVELOPER",
}
View Source
var Group_value = map[string]int32{
	"USER":      0,
	"ADMIN":     1,
	"DEVELOPER": 2,
}

Functions

func RegisterAliveServiceHandler

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

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

func RegisterAliveServiceHandlerClient

func RegisterAliveServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AliveServiceClient) error

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

func RegisterAliveServiceHandlerFromEndpoint

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

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

func RegisterAliveServiceHandlerServer

func RegisterAliveServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AliveServiceServer) error

RegisterAliveServiceHandlerServer registers the http handlers for service AliveService to "mux". UnaryRPC :call AliveServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.

func RegisterAliveServiceServer

func RegisterAliveServiceServer(s *grpc.Server, srv AliveServiceServer)

func RegisterUserServiceHandler

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

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

func RegisterUserServiceHandlerClient

func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UserServiceClient) error

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

func RegisterUserServiceHandlerFromEndpoint

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

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

func RegisterUserServiceHandlerServer

func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UserServiceServer) error

RegisterUserServiceHandlerServer registers the http handlers for service UserService to "mux". UnaryRPC :call UserServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.

func RegisterUserServiceServer

func RegisterUserServiceServer(s *grpc.Server, srv UserServiceServer)

Types

type AliveResponse

type AliveResponse struct {
	Status               bool     `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*AliveResponse) Descriptor

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

func (*AliveResponse) GetStatus

func (m *AliveResponse) GetStatus() bool

func (*AliveResponse) ProtoMessage

func (*AliveResponse) ProtoMessage()

func (*AliveResponse) Reset

func (m *AliveResponse) Reset()

func (*AliveResponse) String

func (m *AliveResponse) String() string

func (*AliveResponse) XXX_DiscardUnknown

func (m *AliveResponse) XXX_DiscardUnknown()

func (*AliveResponse) XXX_Marshal

func (m *AliveResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*AliveResponse) XXX_Merge

func (m *AliveResponse) XXX_Merge(src proto.Message)

func (*AliveResponse) XXX_Size

func (m *AliveResponse) XXX_Size() int

func (*AliveResponse) XXX_Unmarshal

func (m *AliveResponse) XXX_Unmarshal(b []byte) error

type AliveServiceClient

type AliveServiceClient interface {
	GetStatus(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*AliveResponse, error)
}

AliveServiceClient is the client API for AliveService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewAliveServiceClient

func NewAliveServiceClient(cc *grpc.ClientConn) AliveServiceClient

type AliveServiceServer

type AliveServiceServer interface {
	GetStatus(context.Context, *Empty) (*AliveResponse, error)
}

AliveServiceServer is the server API for AliveService service.

type Empty

type Empty struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Empty) Descriptor

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

func (*Empty) ProtoMessage

func (*Empty) ProtoMessage()

func (*Empty) Reset

func (m *Empty) Reset()

func (*Empty) String

func (m *Empty) String() string

func (*Empty) XXX_DiscardUnknown

func (m *Empty) XXX_DiscardUnknown()

func (*Empty) XXX_Marshal

func (m *Empty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Empty) XXX_Merge

func (m *Empty) XXX_Merge(src proto.Message)

func (*Empty) XXX_Size

func (m *Empty) XXX_Size() int

func (*Empty) XXX_Unmarshal

func (m *Empty) XXX_Unmarshal(b []byte) error

type GetUserRequest

type GetUserRequest struct {
	Id                   string   `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*GetUserRequest) Descriptor

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

func (*GetUserRequest) GetId

func (m *GetUserRequest) GetId() string

func (*GetUserRequest) ProtoMessage

func (*GetUserRequest) ProtoMessage()

func (*GetUserRequest) Reset

func (m *GetUserRequest) Reset()

func (*GetUserRequest) String

func (m *GetUserRequest) String() string

func (*GetUserRequest) XXX_DiscardUnknown

func (m *GetUserRequest) XXX_DiscardUnknown()

func (*GetUserRequest) XXX_Marshal

func (m *GetUserRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GetUserRequest) XXX_Merge

func (m *GetUserRequest) XXX_Merge(src proto.Message)

func (*GetUserRequest) XXX_Size

func (m *GetUserRequest) XXX_Size() int

func (*GetUserRequest) XXX_Unmarshal

func (m *GetUserRequest) XXX_Unmarshal(b []byte) error

type Group

type Group int32
const (
	Group_USER      Group = 0
	Group_ADMIN     Group = 1
	Group_DEVELOPER Group = 2
)

func (Group) EnumDescriptor

func (Group) EnumDescriptor() ([]byte, []int)

func (Group) String

func (x Group) String() string

type UnimplementedAliveServiceServer

type UnimplementedAliveServiceServer struct {
}

UnimplementedAliveServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedAliveServiceServer) GetStatus

type UnimplementedUserServiceServer

type UnimplementedUserServiceServer struct {
}

UnimplementedUserServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedUserServiceServer) GetUser

func (*UnimplementedUserServiceServer) GetUsersByGroup

func (*UnimplementedUserServiceServer) UpdateUser

type UpdateUserRequest

type UpdateUserRequest struct {
	Id                   string   `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Name                 string   `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	Age                  int32    `protobuf:"varint,3,opt,name=age,proto3" json:"age,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*UpdateUserRequest) Descriptor

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

func (*UpdateUserRequest) GetAge

func (m *UpdateUserRequest) GetAge() int32

func (*UpdateUserRequest) GetId

func (m *UpdateUserRequest) GetId() string

func (*UpdateUserRequest) GetName

func (m *UpdateUserRequest) GetName() string

func (*UpdateUserRequest) ProtoMessage

func (*UpdateUserRequest) ProtoMessage()

func (*UpdateUserRequest) Reset

func (m *UpdateUserRequest) Reset()

func (*UpdateUserRequest) String

func (m *UpdateUserRequest) String() string

func (*UpdateUserRequest) XXX_DiscardUnknown

func (m *UpdateUserRequest) XXX_DiscardUnknown()

func (*UpdateUserRequest) XXX_Marshal

func (m *UpdateUserRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UpdateUserRequest) XXX_Merge

func (m *UpdateUserRequest) XXX_Merge(src proto.Message)

func (*UpdateUserRequest) XXX_Size

func (m *UpdateUserRequest) XXX_Size() int

func (*UpdateUserRequest) XXX_Unmarshal

func (m *UpdateUserRequest) XXX_Unmarshal(b []byte) error

type UserGroupRequest

type UserGroupRequest struct {
	Group                Group    `protobuf:"varint,1,opt,name=group,proto3,enum=gateway.Group" json:"group,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*UserGroupRequest) Descriptor

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

func (*UserGroupRequest) GetGroup

func (m *UserGroupRequest) GetGroup() Group

func (*UserGroupRequest) ProtoMessage

func (*UserGroupRequest) ProtoMessage()

func (*UserGroupRequest) Reset

func (m *UserGroupRequest) Reset()

func (*UserGroupRequest) String

func (m *UserGroupRequest) String() string

func (*UserGroupRequest) XXX_DiscardUnknown

func (m *UserGroupRequest) XXX_DiscardUnknown()

func (*UserGroupRequest) XXX_Marshal

func (m *UserGroupRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UserGroupRequest) XXX_Merge

func (m *UserGroupRequest) XXX_Merge(src proto.Message)

func (*UserGroupRequest) XXX_Size

func (m *UserGroupRequest) XXX_Size() int

func (*UserGroupRequest) XXX_Unmarshal

func (m *UserGroupRequest) XXX_Unmarshal(b []byte) error

type UserResponse

type UserResponse struct {
	Id                   string   `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Name                 string   `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	Age                  int32    `protobuf:"varint,3,opt,name=age,proto3" json:"age,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*UserResponse) Descriptor

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

func (*UserResponse) GetAge

func (m *UserResponse) GetAge() int32

func (*UserResponse) GetId

func (m *UserResponse) GetId() string

func (*UserResponse) GetName

func (m *UserResponse) GetName() string

func (*UserResponse) ProtoMessage

func (*UserResponse) ProtoMessage()

func (*UserResponse) Reset

func (m *UserResponse) Reset()

func (*UserResponse) String

func (m *UserResponse) String() string

func (*UserResponse) XXX_DiscardUnknown

func (m *UserResponse) XXX_DiscardUnknown()

func (*UserResponse) XXX_Marshal

func (m *UserResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UserResponse) XXX_Merge

func (m *UserResponse) XXX_Merge(src proto.Message)

func (*UserResponse) XXX_Size

func (m *UserResponse) XXX_Size() int

func (*UserResponse) XXX_Unmarshal

func (m *UserResponse) XXX_Unmarshal(b []byte) error

type UserServiceClient

type UserServiceClient interface {
	GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*UserResponse, error)
	GetUsersByGroup(ctx context.Context, in *UserGroupRequest, opts ...grpc.CallOption) (*UsersResponse, error)
	UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...grpc.CallOption) (*Empty, error)
}

UserServiceClient is the client API for UserService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewUserServiceClient

func NewUserServiceClient(cc *grpc.ClientConn) UserServiceClient

type UserServiceServer

type UserServiceServer interface {
	GetUser(context.Context, *GetUserRequest) (*UserResponse, error)
	GetUsersByGroup(context.Context, *UserGroupRequest) (*UsersResponse, error)
	UpdateUser(context.Context, *UpdateUserRequest) (*Empty, error)
}

UserServiceServer is the server API for UserService service.

type UsersResponse

type UsersResponse struct {
	Group                Group           `protobuf:"varint,1,opt,name=group,proto3,enum=gateway.Group" json:"group,omitempty"`
	Users                []*UserResponse `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"`
	XXX_NoUnkeyedLiteral struct{}        `json:"-"`
	XXX_unrecognized     []byte          `json:"-"`
	XXX_sizecache        int32           `json:"-"`
}

func (*UsersResponse) Descriptor

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

func (*UsersResponse) GetGroup

func (m *UsersResponse) GetGroup() Group

func (*UsersResponse) GetUsers

func (m *UsersResponse) GetUsers() []*UserResponse

func (*UsersResponse) ProtoMessage

func (*UsersResponse) ProtoMessage()

func (*UsersResponse) Reset

func (m *UsersResponse) Reset()

func (*UsersResponse) String

func (m *UsersResponse) String() string

func (*UsersResponse) XXX_DiscardUnknown

func (m *UsersResponse) XXX_DiscardUnknown()

func (*UsersResponse) XXX_Marshal

func (m *UsersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UsersResponse) XXX_Merge

func (m *UsersResponse) XXX_Merge(src proto.Message)

func (*UsersResponse) XXX_Size

func (m *UsersResponse) XXX_Size() int

func (*UsersResponse) XXX_Unmarshal

func (m *UsersResponse) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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