Documentation
¶
Index ¶
- Constants
- Variables
- func RegisterUrlShortenerServiceHTTPServer(s *http.Server, srv UrlShortenerServiceHTTPServer)
- func RegisterUrlShortenerServiceServer(s grpc.ServiceRegistrar, srv UrlShortenerServiceServer)
- type CreateUrlReply
- type CreateUrlRequest
- func (*CreateUrlRequest) Descriptor() ([]byte, []int)deprecated
- func (x *CreateUrlRequest) GetBizId() int64
- func (x *CreateUrlRequest) GetExpiredAt() int64
- func (x *CreateUrlRequest) GetShortKey() string
- func (x *CreateUrlRequest) GetUrl() string
- func (*CreateUrlRequest) ProtoMessage()
- func (x *CreateUrlRequest) ProtoReflect() protoreflect.Message
- func (x *CreateUrlRequest) Reset()
- func (x *CreateUrlRequest) String() string
- type ErrorReason
- func (ErrorReason) Descriptor() protoreflect.EnumDescriptor
- func (x ErrorReason) Enum() *ErrorReason
- func (ErrorReason) EnumDescriptor() ([]byte, []int)deprecated
- func (x ErrorReason) Number() protoreflect.EnumNumber
- func (x ErrorReason) String() string
- func (ErrorReason) Type() protoreflect.EnumType
- type JumpReply
- type JumpRequest
- type UnimplementedUrlShortenerServiceServer
- type UnsafeUrlShortenerServiceServer
- type UrlShortenerServiceClient
- type UrlShortenerServiceHTTPClient
- type UrlShortenerServiceHTTPClientImpl
- type UrlShortenerServiceHTTPServer
- type UrlShortenerServiceServer
Constants ¶
const ( UrlShortenerService_CreateShortUrl_FullMethodName = "/url_shorter.v1.UrlShortenerService/CreateShortUrl" UrlShortenerService_GetRedirectURL_FullMethodName = "/url_shorter.v1.UrlShortenerService/GetRedirectURL" )
const OperationUrlShortenerServiceCreateShortUrl = "/url_shorter.v1.UrlShortenerService/CreateShortUrl"
const OperationUrlShortenerServiceGetRedirectURL = "/url_shorter.v1.UrlShortenerService/GetRedirectURL"
Variables ¶
var ( ErrorReason_name = map[int32]string{ 0: "SUCCESS", 1: "USER_NOT_FOUND", } ErrorReason_value = map[string]int32{ "SUCCESS": 0, "USER_NOT_FOUND": 1, } )
Enum value maps for ErrorReason.
var File_url_shorter_v1_error_reason_proto protoreflect.FileDescriptor
var File_url_shorter_v1_url_shorter_proto protoreflect.FileDescriptor
var UrlShortenerService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "url_shorter.v1.UrlShortenerService", HandlerType: (*UrlShortenerServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "CreateShortUrl", Handler: _UrlShortenerService_CreateShortUrl_Handler, }, { MethodName: "GetRedirectURL", Handler: _UrlShortenerService_GetRedirectURL_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "url_shorter/v1/url_shorter.proto", }
UrlShortenerService_ServiceDesc is the grpc.ServiceDesc for UrlShortenerService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterUrlShortenerServiceHTTPServer ¶
func RegisterUrlShortenerServiceHTTPServer(s *http.Server, srv UrlShortenerServiceHTTPServer)
func RegisterUrlShortenerServiceServer ¶
func RegisterUrlShortenerServiceServer(s grpc.ServiceRegistrar, srv UrlShortenerServiceServer)
Types ¶
type CreateUrlReply ¶
type CreateUrlReply struct { // The created short URL. Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` // contains filtered or unexported fields }
CreateUrlReply contains the generated short URL as a response.
func (*CreateUrlReply) Descriptor
deprecated
func (*CreateUrlReply) Descriptor() ([]byte, []int)
Deprecated: Use CreateUrlReply.ProtoReflect.Descriptor instead.
func (*CreateUrlReply) GetUrl ¶
func (x *CreateUrlReply) GetUrl() string
func (*CreateUrlReply) ProtoMessage ¶
func (*CreateUrlReply) ProtoMessage()
func (*CreateUrlReply) ProtoReflect ¶
func (x *CreateUrlReply) ProtoReflect() protoreflect.Message
func (*CreateUrlReply) Reset ¶
func (x *CreateUrlReply) Reset()
func (*CreateUrlReply) String ¶
func (x *CreateUrlReply) String() string
type CreateUrlRequest ¶
type CreateUrlRequest struct { // The original long URL to be shortened (required). Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` // The custom short key for the short URL (optional). ShortKey string `protobuf:"bytes,2,opt,name=short_key,proto3" json:"short_key,omitempty"` // The business ID associated with the short URL (optional). BizId int64 `protobuf:"varint,3,opt,name=biz_id,proto3" json:"biz_id,omitempty"` // The expiration timestamp for the short URL (optional). ExpiredAt int64 `protobuf:"varint,4,opt,name=expired_at,proto3" json:"expired_at,omitempty"` // contains filtered or unexported fields }
CreateUrlRequest represents the input parameters required to create a new short URL.
func (*CreateUrlRequest) Descriptor
deprecated
func (*CreateUrlRequest) Descriptor() ([]byte, []int)
Deprecated: Use CreateUrlRequest.ProtoReflect.Descriptor instead.
func (*CreateUrlRequest) GetBizId ¶
func (x *CreateUrlRequest) GetBizId() int64
func (*CreateUrlRequest) GetExpiredAt ¶
func (x *CreateUrlRequest) GetExpiredAt() int64
func (*CreateUrlRequest) GetShortKey ¶
func (x *CreateUrlRequest) GetShortKey() string
func (*CreateUrlRequest) GetUrl ¶
func (x *CreateUrlRequest) GetUrl() string
func (*CreateUrlRequest) ProtoMessage ¶
func (*CreateUrlRequest) ProtoMessage()
func (*CreateUrlRequest) ProtoReflect ¶
func (x *CreateUrlRequest) ProtoReflect() protoreflect.Message
func (*CreateUrlRequest) Reset ¶
func (x *CreateUrlRequest) Reset()
func (*CreateUrlRequest) String ¶
func (x *CreateUrlRequest) String() string
type ErrorReason ¶
type ErrorReason int32
const ( ErrorReason_SUCCESS ErrorReason = 0 ErrorReason_USER_NOT_FOUND ErrorReason = 1 )
func (ErrorReason) Descriptor ¶
func (ErrorReason) Descriptor() protoreflect.EnumDescriptor
func (ErrorReason) Enum ¶
func (x ErrorReason) Enum() *ErrorReason
func (ErrorReason) EnumDescriptor
deprecated
func (ErrorReason) EnumDescriptor() ([]byte, []int)
Deprecated: Use ErrorReason.Descriptor instead.
func (ErrorReason) Number ¶
func (x ErrorReason) Number() protoreflect.EnumNumber
func (ErrorReason) String ¶
func (x ErrorReason) String() string
func (ErrorReason) Type ¶
func (ErrorReason) Type() protoreflect.EnumType
type JumpReply ¶
type JumpReply struct { // The ID associated with the short URL. Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // The original long URL associated with the short URL. Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` // contains filtered or unexported fields }
JumpReply contains the retrieved long URL as a response.
func (*JumpReply) Descriptor
deprecated
func (*JumpReply) ProtoMessage ¶
func (*JumpReply) ProtoMessage()
func (*JumpReply) ProtoReflect ¶
func (x *JumpReply) ProtoReflect() protoreflect.Message
type JumpRequest ¶
type JumpRequest struct { // The short URL to be used for the lookup (required).. Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` // contains filtered or unexported fields }
JumpRequest represents the input parameters required to retrieve the long URL associated with a short URL.
func (*JumpRequest) Descriptor
deprecated
func (*JumpRequest) Descriptor() ([]byte, []int)
Deprecated: Use JumpRequest.ProtoReflect.Descriptor instead.
func (*JumpRequest) GetUrl ¶
func (x *JumpRequest) GetUrl() string
func (*JumpRequest) ProtoMessage ¶
func (*JumpRequest) ProtoMessage()
func (*JumpRequest) ProtoReflect ¶
func (x *JumpRequest) ProtoReflect() protoreflect.Message
func (*JumpRequest) Reset ¶
func (x *JumpRequest) Reset()
func (*JumpRequest) String ¶
func (x *JumpRequest) String() string
type UnimplementedUrlShortenerServiceServer ¶
type UnimplementedUrlShortenerServiceServer struct { }
UnimplementedUrlShortenerServiceServer must be embedded to have forward compatible implementations.
func (UnimplementedUrlShortenerServiceServer) CreateShortUrl ¶
func (UnimplementedUrlShortenerServiceServer) CreateShortUrl(context.Context, *CreateUrlRequest) (*CreateUrlReply, error)
func (UnimplementedUrlShortenerServiceServer) GetRedirectURL ¶
func (UnimplementedUrlShortenerServiceServer) GetRedirectURL(context.Context, *JumpRequest) (*JumpReply, error)
type UnsafeUrlShortenerServiceServer ¶
type UnsafeUrlShortenerServiceServer interface {
// contains filtered or unexported methods
}
UnsafeUrlShortenerServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to UrlShortenerServiceServer will result in compilation errors.
type UrlShortenerServiceClient ¶
type UrlShortenerServiceClient interface { // CreateUrlShortener creates a new short URL based on the provided long URL, short key, and biz tag. CreateShortUrl(ctx context.Context, in *CreateUrlRequest, opts ...grpc.CallOption) (*CreateUrlReply, error) // GetRedirectURL retrieves the long URL associated with the given short URL and returns it to the client. GetRedirectURL(ctx context.Context, in *JumpRequest, opts ...grpc.CallOption) (*JumpReply, error) }
UrlShortenerServiceClient is the client API for UrlShortenerService service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkgo.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
func NewUrlShortenerServiceClient ¶
func NewUrlShortenerServiceClient(cc grpc.ClientConnInterface) UrlShortenerServiceClient
type UrlShortenerServiceHTTPClient ¶
type UrlShortenerServiceHTTPClient interface { CreateShortUrl(ctx context.Context, req *CreateUrlRequest, opts ...http.CallOption) (rsp *CreateUrlReply, err error) GetRedirectURL(ctx context.Context, req *JumpRequest, opts ...http.CallOption) (rsp *JumpReply, err error) }
func NewUrlShortenerServiceHTTPClient ¶
func NewUrlShortenerServiceHTTPClient(client *http.Client) UrlShortenerServiceHTTPClient
type UrlShortenerServiceHTTPClientImpl ¶
type UrlShortenerServiceHTTPClientImpl struct {
// contains filtered or unexported fields
}
func (*UrlShortenerServiceHTTPClientImpl) CreateShortUrl ¶
func (c *UrlShortenerServiceHTTPClientImpl) CreateShortUrl(ctx context.Context, in *CreateUrlRequest, opts ...http.CallOption) (*CreateUrlReply, error)
func (*UrlShortenerServiceHTTPClientImpl) GetRedirectURL ¶
func (c *UrlShortenerServiceHTTPClientImpl) GetRedirectURL(ctx context.Context, in *JumpRequest, opts ...http.CallOption) (*JumpReply, error)
type UrlShortenerServiceHTTPServer ¶
type UrlShortenerServiceHTTPServer interface { // CreateShortUrl CreateUrlShortener creates a new short URL based on the provided long URL, short key, and biz tag. CreateShortUrl(context.Context, *CreateUrlRequest) (*CreateUrlReply, error) // GetRedirectURL GetRedirectURL retrieves the long URL associated with the given short URL and returns it to the client. GetRedirectURL(context.Context, *JumpRequest) (*JumpReply, error) }
type UrlShortenerServiceServer ¶
type UrlShortenerServiceServer interface { // CreateUrlShortener creates a new short URL based on the provided long URL, short key, and biz tag. CreateShortUrl(context.Context, *CreateUrlRequest) (*CreateUrlReply, error) // GetRedirectURL retrieves the long URL associated with the given short URL and returns it to the client. GetRedirectURL(context.Context, *JumpRequest) (*JumpReply, error) // contains filtered or unexported methods }
UrlShortenerServiceServer is the server API for UrlShortenerService service. All implementations must embed UnimplementedUrlShortenerServiceServer for forward compatibility