Documentation ¶
Overview ¶
Package api is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Variables
- func RegisterApiHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterApiHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ApiClient) error
- func RegisterApiHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ApiServer) error
- func RegisterApiServer(s grpc.ServiceRegistrar, srv ApiServer)
- type ApiClient
- type ApiServer
- type ResponseError
- type ResponseErrors
- type TranslateTextData
- func (*TranslateTextData) Descriptor() ([]byte, []int)deprecated
- func (x *TranslateTextData) GetTook() float32
- func (x *TranslateTextData) GetTranslatedText() string
- func (*TranslateTextData) ProtoMessage()
- func (x *TranslateTextData) ProtoReflect() protoreflect.Message
- func (x *TranslateTextData) Reset()
- func (x *TranslateTextData) String() string
- type TranslateTextInput
- func (*TranslateTextInput) Descriptor() ([]byte, []int)deprecated
- func (x *TranslateTextInput) GetSourceLanguage() string
- func (x *TranslateTextInput) GetTargetLanguage() string
- func (x *TranslateTextInput) GetText() string
- func (*TranslateTextInput) ProtoMessage()
- func (x *TranslateTextInput) ProtoReflect() protoreflect.Message
- func (x *TranslateTextInput) Reset()
- func (x *TranslateTextInput) String() string
- type TranslateTextRequest
- func (*TranslateTextRequest) Descriptor() ([]byte, []int)deprecated
- func (x *TranslateTextRequest) GetTranslateTextInput() *TranslateTextInput
- func (*TranslateTextRequest) ProtoMessage()
- func (x *TranslateTextRequest) ProtoReflect() protoreflect.Message
- func (x *TranslateTextRequest) Reset()
- func (x *TranslateTextRequest) String() string
- type TranslateTextResponse
- func (*TranslateTextResponse) Descriptor() ([]byte, []int)deprecated
- func (x *TranslateTextResponse) GetData() *TranslateTextData
- func (x *TranslateTextResponse) GetErrors() *ResponseErrors
- func (*TranslateTextResponse) ProtoMessage()
- func (x *TranslateTextResponse) ProtoReflect() protoreflect.Message
- func (x *TranslateTextResponse) Reset()
- func (x *TranslateTextResponse) String() string
- type UnimplementedApiServer
- type UnsafeApiServer
Constants ¶
This section is empty.
Variables ¶
var Api_ServiceDesc = grpc.ServiceDesc{ ServiceName: "api.Api", HandlerType: (*ApiServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "TranslateText", Handler: _Api_TranslateText_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "api.proto", }
Api_ServiceDesc is the grpc.ServiceDesc for Api service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
var File_api_proto protoreflect.FileDescriptor
Functions ¶
func RegisterApiHandler ¶
RegisterApiHandler registers the http handlers for service Api to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterApiHandlerClient ¶
RegisterApiHandlerClient registers the http handlers for service Api to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ApiClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ApiClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "ApiClient" to call the correct interceptors.
func RegisterApiHandlerFromEndpoint ¶
func RegisterApiHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterApiHandlerFromEndpoint is same as RegisterApiHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterApiHandlerServer ¶
RegisterApiHandlerServer registers the http handlers for service Api to "mux". UnaryRPC :call ApiServer 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 RegisterApiHandlerFromEndpoint instead.
func RegisterApiServer ¶
func RegisterApiServer(s grpc.ServiceRegistrar, srv ApiServer)
Types ¶
type ApiClient ¶
type ApiClient interface {
TranslateText(ctx context.Context, in *TranslateTextRequest, opts ...grpc.CallOption) (*TranslateTextResponse, error)
}
ApiClient is the client API for Api 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 NewApiClient ¶
func NewApiClient(cc grpc.ClientConnInterface) ApiClient
type ApiServer ¶
type ApiServer interface { TranslateText(context.Context, *TranslateTextRequest) (*TranslateTextResponse, error) // contains filtered or unexported methods }
ApiServer is the server API for Api service. All implementations must embed UnimplementedApiServer for forward compatibility
type ResponseError ¶
type ResponseError struct { Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` // contains filtered or unexported fields }
func (*ResponseError) Descriptor
deprecated
func (*ResponseError) Descriptor() ([]byte, []int)
Deprecated: Use ResponseError.ProtoReflect.Descriptor instead.
func (*ResponseError) GetMessage ¶
func (x *ResponseError) GetMessage() string
func (*ResponseError) ProtoMessage ¶
func (*ResponseError) ProtoMessage()
func (*ResponseError) ProtoReflect ¶
func (x *ResponseError) ProtoReflect() protoreflect.Message
func (*ResponseError) Reset ¶
func (x *ResponseError) Reset()
func (*ResponseError) String ¶
func (x *ResponseError) String() string
type ResponseErrors ¶
type ResponseErrors struct { Value []*ResponseError `protobuf:"bytes,1,rep,name=value,proto3" json:"value,omitempty"` // contains filtered or unexported fields }
func (*ResponseErrors) Descriptor
deprecated
func (*ResponseErrors) Descriptor() ([]byte, []int)
Deprecated: Use ResponseErrors.ProtoReflect.Descriptor instead.
func (*ResponseErrors) GetValue ¶
func (x *ResponseErrors) GetValue() []*ResponseError
func (*ResponseErrors) ProtoMessage ¶
func (*ResponseErrors) ProtoMessage()
func (*ResponseErrors) ProtoReflect ¶
func (x *ResponseErrors) ProtoReflect() protoreflect.Message
func (*ResponseErrors) Reset ¶
func (x *ResponseErrors) Reset()
func (*ResponseErrors) String ¶
func (x *ResponseErrors) String() string
type TranslateTextData ¶
type TranslateTextData struct { Took float32 `protobuf:"fixed32,1,opt,name=took,proto3" json:"took,omitempty"` TranslatedText string `protobuf:"bytes,2,opt,name=translated_text,json=translatedText,proto3" json:"translated_text,omitempty"` // contains filtered or unexported fields }
func (*TranslateTextData) Descriptor
deprecated
func (*TranslateTextData) Descriptor() ([]byte, []int)
Deprecated: Use TranslateTextData.ProtoReflect.Descriptor instead.
func (*TranslateTextData) GetTook ¶
func (x *TranslateTextData) GetTook() float32
func (*TranslateTextData) GetTranslatedText ¶
func (x *TranslateTextData) GetTranslatedText() string
func (*TranslateTextData) ProtoMessage ¶
func (*TranslateTextData) ProtoMessage()
func (*TranslateTextData) ProtoReflect ¶
func (x *TranslateTextData) ProtoReflect() protoreflect.Message
func (*TranslateTextData) Reset ¶
func (x *TranslateTextData) Reset()
func (*TranslateTextData) String ¶
func (x *TranslateTextData) String() string
type TranslateTextInput ¶
type TranslateTextInput struct { SourceLanguage string `protobuf:"bytes,1,opt,name=source_language,json=sourceLanguage,proto3" json:"source_language,omitempty"` TargetLanguage string `protobuf:"bytes,2,opt,name=target_language,json=targetLanguage,proto3" json:"target_language,omitempty"` Text string `protobuf:"bytes,3,opt,name=text,proto3" json:"text,omitempty"` // contains filtered or unexported fields }
func (*TranslateTextInput) Descriptor
deprecated
func (*TranslateTextInput) Descriptor() ([]byte, []int)
Deprecated: Use TranslateTextInput.ProtoReflect.Descriptor instead.
func (*TranslateTextInput) GetSourceLanguage ¶
func (x *TranslateTextInput) GetSourceLanguage() string
func (*TranslateTextInput) GetTargetLanguage ¶
func (x *TranslateTextInput) GetTargetLanguage() string
func (*TranslateTextInput) GetText ¶
func (x *TranslateTextInput) GetText() string
func (*TranslateTextInput) ProtoMessage ¶
func (*TranslateTextInput) ProtoMessage()
func (*TranslateTextInput) ProtoReflect ¶
func (x *TranslateTextInput) ProtoReflect() protoreflect.Message
func (*TranslateTextInput) Reset ¶
func (x *TranslateTextInput) Reset()
func (*TranslateTextInput) String ¶
func (x *TranslateTextInput) String() string
type TranslateTextRequest ¶
type TranslateTextRequest struct { TranslateTextInput *TranslateTextInput `protobuf:"bytes,1,opt,name=translate_text_input,json=translateTextInput,proto3" json:"translate_text_input,omitempty"` // contains filtered or unexported fields }
TranslateTextParameters holds parameters to TranslateText
func (*TranslateTextRequest) Descriptor
deprecated
func (*TranslateTextRequest) Descriptor() ([]byte, []int)
Deprecated: Use TranslateTextRequest.ProtoReflect.Descriptor instead.
func (*TranslateTextRequest) GetTranslateTextInput ¶
func (x *TranslateTextRequest) GetTranslateTextInput() *TranslateTextInput
func (*TranslateTextRequest) ProtoMessage ¶
func (*TranslateTextRequest) ProtoMessage()
func (*TranslateTextRequest) ProtoReflect ¶
func (x *TranslateTextRequest) ProtoReflect() protoreflect.Message
func (*TranslateTextRequest) Reset ¶
func (x *TranslateTextRequest) Reset()
func (*TranslateTextRequest) String ¶
func (x *TranslateTextRequest) String() string
type TranslateTextResponse ¶
type TranslateTextResponse struct { Data *TranslateTextData `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` Errors *ResponseErrors `protobuf:"bytes,2,opt,name=errors,proto3" json:"errors,omitempty"` // contains filtered or unexported fields }
func (*TranslateTextResponse) Descriptor
deprecated
func (*TranslateTextResponse) Descriptor() ([]byte, []int)
Deprecated: Use TranslateTextResponse.ProtoReflect.Descriptor instead.
func (*TranslateTextResponse) GetData ¶
func (x *TranslateTextResponse) GetData() *TranslateTextData
func (*TranslateTextResponse) GetErrors ¶
func (x *TranslateTextResponse) GetErrors() *ResponseErrors
func (*TranslateTextResponse) ProtoMessage ¶
func (*TranslateTextResponse) ProtoMessage()
func (*TranslateTextResponse) ProtoReflect ¶
func (x *TranslateTextResponse) ProtoReflect() protoreflect.Message
func (*TranslateTextResponse) Reset ¶
func (x *TranslateTextResponse) Reset()
func (*TranslateTextResponse) String ¶
func (x *TranslateTextResponse) String() string
type UnimplementedApiServer ¶
type UnimplementedApiServer struct { }
UnimplementedApiServer must be embedded to have forward compatible implementations.
func (UnimplementedApiServer) TranslateText ¶
func (UnimplementedApiServer) TranslateText(context.Context, *TranslateTextRequest) (*TranslateTextResponse, error)
type UnsafeApiServer ¶
type UnsafeApiServer interface {
// contains filtered or unexported methods
}
UnsafeApiServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ApiServer will result in compilation errors.