Documentation ¶
Overview ¶
Package shortenerv1 is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Variables
- func RegisterURLShortenerServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterURLShortenerServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client URLShortenerServiceClient) error
- func RegisterURLShortenerServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterURLShortenerServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server URLShortenerServiceServer) error
- func RegisterURLShortenerServiceServer(s grpc.ServiceRegistrar, srv URLShortenerServiceServer)
- type CreateShortURLRequest
- func (*CreateShortURLRequest) Descriptor() ([]byte, []int)deprecated
- func (x *CreateShortURLRequest) GetOriginalUrl() string
- func (*CreateShortURLRequest) ProtoMessage()
- func (x *CreateShortURLRequest) ProtoReflect() protoreflect.Message
- func (x *CreateShortURLRequest) Reset()
- func (x *CreateShortURLRequest) String() string
- type CreateShortURLResponse
- func (*CreateShortURLResponse) Descriptor() ([]byte, []int)deprecated
- func (x *CreateShortURLResponse) GetUrl() *URL
- func (*CreateShortURLResponse) ProtoMessage()
- func (x *CreateShortURLResponse) ProtoReflect() protoreflect.Message
- func (x *CreateShortURLResponse) Reset()
- func (x *CreateShortURLResponse) String() string
- type GetAllURLRequest
- type GetAllURLResponse
- type GetURLDetailRequest
- func (*GetURLDetailRequest) Descriptor() ([]byte, []int)deprecated
- func (x *GetURLDetailRequest) GetCode() string
- func (*GetURLDetailRequest) ProtoMessage()
- func (x *GetURLDetailRequest) ProtoReflect() protoreflect.Message
- func (x *GetURLDetailRequest) Reset()
- func (x *GetURLDetailRequest) String() string
- type GetURLDetailResponse
- func (*GetURLDetailResponse) Descriptor() ([]byte, []int)deprecated
- func (x *GetURLDetailResponse) GetUrl() *URL
- func (*GetURLDetailResponse) ProtoMessage()
- func (x *GetURLDetailResponse) ProtoReflect() protoreflect.Message
- func (x *GetURLDetailResponse) Reset()
- func (x *GetURLDetailResponse) String() string
- type StreamAllURLRequest
- type StreamAllURLResponse
- func (*StreamAllURLResponse) Descriptor() ([]byte, []int)deprecated
- func (x *StreamAllURLResponse) GetUrl() *URL
- func (*StreamAllURLResponse) ProtoMessage()
- func (x *StreamAllURLResponse) ProtoReflect() protoreflect.Message
- func (x *StreamAllURLResponse) Reset()
- func (x *StreamAllURLResponse) String() string
- type URL
- func (*URL) Descriptor() ([]byte, []int)deprecated
- func (x *URL) GetCode() string
- func (x *URL) GetCreatedAt() *timestamppb.Timestamp
- func (x *URL) GetExpiredAt() *timestamppb.Timestamp
- func (x *URL) GetOriginalUrl() string
- func (x *URL) GetShortUrl() string
- func (*URL) ProtoMessage()
- func (x *URL) ProtoReflect() protoreflect.Message
- func (x *URL) Reset()
- func (x *URL) String() string
- type URLShortenerError
- func (*URLShortenerError) Descriptor() ([]byte, []int)deprecated
- func (x *URLShortenerError) GetErrorCode() URLShortenerErrorCode
- func (*URLShortenerError) ProtoMessage()
- func (x *URLShortenerError) ProtoReflect() protoreflect.Message
- func (x *URLShortenerError) Reset()
- func (x *URLShortenerError) String() string
- type URLShortenerErrorCode
- func (URLShortenerErrorCode) Descriptor() protoreflect.EnumDescriptor
- func (x URLShortenerErrorCode) Enum() *URLShortenerErrorCode
- func (URLShortenerErrorCode) EnumDescriptor() ([]byte, []int)deprecated
- func (x URLShortenerErrorCode) Number() protoreflect.EnumNumber
- func (x URLShortenerErrorCode) String() string
- func (URLShortenerErrorCode) Type() protoreflect.EnumType
- type URLShortenerServiceClient
- type URLShortenerServiceServer
- type URLShortenerService_StreamAllURLClient
- type URLShortenerService_StreamAllURLServer
- type UnimplementedURLShortenerServiceServer
- func (UnimplementedURLShortenerServiceServer) CreateShortURL(context.Context, *CreateShortURLRequest) (*CreateShortURLResponse, error)
- func (UnimplementedURLShortenerServiceServer) GetAllURL(context.Context, *GetAllURLRequest) (*GetAllURLResponse, error)
- func (UnimplementedURLShortenerServiceServer) GetURLDetail(context.Context, *GetURLDetailRequest) (*GetURLDetailResponse, error)
- func (UnimplementedURLShortenerServiceServer) StreamAllURL(*StreamAllURLRequest, URLShortenerService_StreamAllURLServer) error
- type UnsafeURLShortenerServiceServer
Constants ¶
This section is empty.
Variables ¶
var ( URLShortenerErrorCode_name = map[int32]string{ 0: "UNKNOWN_URL_SHORTENER_ERROR_CODE", 1: "INTERNAL", 2: "EMPTY_URL", 3: "ALREADY_EXISTS", 4: "NOT_FOUND", } URLShortenerErrorCode_value = map[string]int32{ "UNKNOWN_URL_SHORTENER_ERROR_CODE": 0, "INTERNAL": 1, "EMPTY_URL": 2, "ALREADY_EXISTS": 3, "NOT_FOUND": 4, } )
Enum value maps for URLShortenerErrorCode.
var File_proto_indrasaputra_shortener_v1_shortener_proto protoreflect.FileDescriptor
var URLShortenerService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "proto.indrasaputra.shortener.v1.URLShortenerService", HandlerType: (*URLShortenerServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "CreateShortURL", Handler: _URLShortenerService_CreateShortURL_Handler, }, { MethodName: "GetAllURL", Handler: _URLShortenerService_GetAllURL_Handler, }, { MethodName: "GetURLDetail", Handler: _URLShortenerService_GetURLDetail_Handler, }, }, Streams: []grpc.StreamDesc{ { StreamName: "StreamAllURL", Handler: _URLShortenerService_StreamAllURL_Handler, ServerStreams: true, }, }, Metadata: "proto/indrasaputra/shortener/v1/shortener.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 RegisterURLShortenerServiceHandler ¶
func RegisterURLShortenerServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
RegisterURLShortenerServiceHandler registers the http handlers for service URLShortenerService to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterURLShortenerServiceHandlerClient ¶
func RegisterURLShortenerServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client URLShortenerServiceClient) error
RegisterURLShortenerServiceHandlerClient registers the http handlers for service URLShortenerService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "URLShortenerServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "URLShortenerServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "URLShortenerServiceClient" to call the correct interceptors.
func RegisterURLShortenerServiceHandlerFromEndpoint ¶
func RegisterURLShortenerServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterURLShortenerServiceHandlerFromEndpoint is same as RegisterURLShortenerServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterURLShortenerServiceHandlerServer ¶
func RegisterURLShortenerServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server URLShortenerServiceServer) error
RegisterURLShortenerServiceHandlerServer registers the http handlers for service URLShortenerService to "mux". UnaryRPC :call URLShortenerServiceServer 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 RegisterURLShortenerServiceHandlerFromEndpoint instead.
func RegisterURLShortenerServiceServer ¶
func RegisterURLShortenerServiceServer(s grpc.ServiceRegistrar, srv URLShortenerServiceServer)
Types ¶
type CreateShortURLRequest ¶
type CreateShortURLRequest struct { OriginalUrl string `protobuf:"bytes,1,opt,name=original_url,json=originalUrl,proto3" json:"original_url,omitempty"` // contains filtered or unexported fields }
func (*CreateShortURLRequest) Descriptor
deprecated
func (*CreateShortURLRequest) Descriptor() ([]byte, []int)
Deprecated: Use CreateShortURLRequest.ProtoReflect.Descriptor instead.
func (*CreateShortURLRequest) GetOriginalUrl ¶
func (x *CreateShortURLRequest) GetOriginalUrl() string
func (*CreateShortURLRequest) ProtoMessage ¶
func (*CreateShortURLRequest) ProtoMessage()
func (*CreateShortURLRequest) ProtoReflect ¶
func (x *CreateShortURLRequest) ProtoReflect() protoreflect.Message
func (*CreateShortURLRequest) Reset ¶
func (x *CreateShortURLRequest) Reset()
func (*CreateShortURLRequest) String ¶
func (x *CreateShortURLRequest) String() string
type CreateShortURLResponse ¶
type CreateShortURLResponse struct { Url *URL `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` // contains filtered or unexported fields }
func (*CreateShortURLResponse) Descriptor
deprecated
func (*CreateShortURLResponse) Descriptor() ([]byte, []int)
Deprecated: Use CreateShortURLResponse.ProtoReflect.Descriptor instead.
func (*CreateShortURLResponse) GetUrl ¶
func (x *CreateShortURLResponse) GetUrl() *URL
func (*CreateShortURLResponse) ProtoMessage ¶
func (*CreateShortURLResponse) ProtoMessage()
func (*CreateShortURLResponse) ProtoReflect ¶
func (x *CreateShortURLResponse) ProtoReflect() protoreflect.Message
func (*CreateShortURLResponse) Reset ¶
func (x *CreateShortURLResponse) Reset()
func (*CreateShortURLResponse) String ¶
func (x *CreateShortURLResponse) String() string
type GetAllURLRequest ¶
type GetAllURLRequest struct {
// contains filtered or unexported fields
}
func (*GetAllURLRequest) Descriptor
deprecated
func (*GetAllURLRequest) Descriptor() ([]byte, []int)
Deprecated: Use GetAllURLRequest.ProtoReflect.Descriptor instead.
func (*GetAllURLRequest) ProtoMessage ¶
func (*GetAllURLRequest) ProtoMessage()
func (*GetAllURLRequest) ProtoReflect ¶
func (x *GetAllURLRequest) ProtoReflect() protoreflect.Message
func (*GetAllURLRequest) Reset ¶
func (x *GetAllURLRequest) Reset()
func (*GetAllURLRequest) String ¶
func (x *GetAllURLRequest) String() string
type GetAllURLResponse ¶
type GetAllURLResponse struct { Urls []*URL `protobuf:"bytes,1,rep,name=urls,proto3" json:"urls,omitempty"` // contains filtered or unexported fields }
func (*GetAllURLResponse) Descriptor
deprecated
func (*GetAllURLResponse) Descriptor() ([]byte, []int)
Deprecated: Use GetAllURLResponse.ProtoReflect.Descriptor instead.
func (*GetAllURLResponse) GetUrls ¶
func (x *GetAllURLResponse) GetUrls() []*URL
func (*GetAllURLResponse) ProtoMessage ¶
func (*GetAllURLResponse) ProtoMessage()
func (*GetAllURLResponse) ProtoReflect ¶
func (x *GetAllURLResponse) ProtoReflect() protoreflect.Message
func (*GetAllURLResponse) Reset ¶
func (x *GetAllURLResponse) Reset()
func (*GetAllURLResponse) String ¶
func (x *GetAllURLResponse) String() string
type GetURLDetailRequest ¶
type GetURLDetailRequest struct { Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` // contains filtered or unexported fields }
func (*GetURLDetailRequest) Descriptor
deprecated
func (*GetURLDetailRequest) Descriptor() ([]byte, []int)
Deprecated: Use GetURLDetailRequest.ProtoReflect.Descriptor instead.
func (*GetURLDetailRequest) GetCode ¶
func (x *GetURLDetailRequest) GetCode() string
func (*GetURLDetailRequest) ProtoMessage ¶
func (*GetURLDetailRequest) ProtoMessage()
func (*GetURLDetailRequest) ProtoReflect ¶
func (x *GetURLDetailRequest) ProtoReflect() protoreflect.Message
func (*GetURLDetailRequest) Reset ¶
func (x *GetURLDetailRequest) Reset()
func (*GetURLDetailRequest) String ¶
func (x *GetURLDetailRequest) String() string
type GetURLDetailResponse ¶
type GetURLDetailResponse struct { Url *URL `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` // contains filtered or unexported fields }
func (*GetURLDetailResponse) Descriptor
deprecated
func (*GetURLDetailResponse) Descriptor() ([]byte, []int)
Deprecated: Use GetURLDetailResponse.ProtoReflect.Descriptor instead.
func (*GetURLDetailResponse) GetUrl ¶
func (x *GetURLDetailResponse) GetUrl() *URL
func (*GetURLDetailResponse) ProtoMessage ¶
func (*GetURLDetailResponse) ProtoMessage()
func (*GetURLDetailResponse) ProtoReflect ¶
func (x *GetURLDetailResponse) ProtoReflect() protoreflect.Message
func (*GetURLDetailResponse) Reset ¶
func (x *GetURLDetailResponse) Reset()
func (*GetURLDetailResponse) String ¶
func (x *GetURLDetailResponse) String() string
type StreamAllURLRequest ¶
type StreamAllURLRequest struct {
// contains filtered or unexported fields
}
func (*StreamAllURLRequest) Descriptor
deprecated
func (*StreamAllURLRequest) Descriptor() ([]byte, []int)
Deprecated: Use StreamAllURLRequest.ProtoReflect.Descriptor instead.
func (*StreamAllURLRequest) ProtoMessage ¶
func (*StreamAllURLRequest) ProtoMessage()
func (*StreamAllURLRequest) ProtoReflect ¶
func (x *StreamAllURLRequest) ProtoReflect() protoreflect.Message
func (*StreamAllURLRequest) Reset ¶
func (x *StreamAllURLRequest) Reset()
func (*StreamAllURLRequest) String ¶
func (x *StreamAllURLRequest) String() string
type StreamAllURLResponse ¶
type StreamAllURLResponse struct { Url *URL `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` // contains filtered or unexported fields }
func (*StreamAllURLResponse) Descriptor
deprecated
func (*StreamAllURLResponse) Descriptor() ([]byte, []int)
Deprecated: Use StreamAllURLResponse.ProtoReflect.Descriptor instead.
func (*StreamAllURLResponse) GetUrl ¶
func (x *StreamAllURLResponse) GetUrl() *URL
func (*StreamAllURLResponse) ProtoMessage ¶
func (*StreamAllURLResponse) ProtoMessage()
func (*StreamAllURLResponse) ProtoReflect ¶
func (x *StreamAllURLResponse) ProtoReflect() protoreflect.Message
func (*StreamAllURLResponse) Reset ¶
func (x *StreamAllURLResponse) Reset()
func (*StreamAllURLResponse) String ¶
func (x *StreamAllURLResponse) String() string
type URL ¶
type URL struct { Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` ShortUrl string `protobuf:"bytes,2,opt,name=short_url,json=shortUrl,proto3" json:"short_url,omitempty"` OriginalUrl string `protobuf:"bytes,3,opt,name=original_url,json=originalUrl,proto3" json:"original_url,omitempty"` ExpiredAt *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=expired_at,json=expiredAt,proto3" json:"expired_at,omitempty"` CreatedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` // contains filtered or unexported fields }
func (*URL) Descriptor
deprecated
func (*URL) GetCreatedAt ¶
func (x *URL) GetCreatedAt() *timestamppb.Timestamp
func (*URL) GetExpiredAt ¶
func (x *URL) GetExpiredAt() *timestamppb.Timestamp
func (*URL) GetOriginalUrl ¶
func (*URL) GetShortUrl ¶
func (*URL) ProtoMessage ¶
func (*URL) ProtoMessage()
func (*URL) ProtoReflect ¶
func (x *URL) ProtoReflect() protoreflect.Message
type URLShortenerError ¶
type URLShortenerError struct { ErrorCode URLShortenerErrorCode `` /* 148-byte string literal not displayed */ // contains filtered or unexported fields }
func (*URLShortenerError) Descriptor
deprecated
func (*URLShortenerError) Descriptor() ([]byte, []int)
Deprecated: Use URLShortenerError.ProtoReflect.Descriptor instead.
func (*URLShortenerError) GetErrorCode ¶
func (x *URLShortenerError) GetErrorCode() URLShortenerErrorCode
func (*URLShortenerError) ProtoMessage ¶
func (*URLShortenerError) ProtoMessage()
func (*URLShortenerError) ProtoReflect ¶
func (x *URLShortenerError) ProtoReflect() protoreflect.Message
func (*URLShortenerError) Reset ¶
func (x *URLShortenerError) Reset()
func (*URLShortenerError) String ¶
func (x *URLShortenerError) String() string
type URLShortenerErrorCode ¶
type URLShortenerErrorCode int32
const ( // Default enum code according to // https://medium.com/@akhaku/protobuf-definition-best-practices-87f281576f31. URLShortenerErrorCode_UNKNOWN_URL_SHORTENER_ERROR_CODE URLShortenerErrorCode = 0 // Unexpected behavior occured in system. URLShortenerErrorCode_INTERNAL URLShortenerErrorCode = 1 // URL instance is empty or nil. URLShortenerErrorCode_EMPTY_URL URLShortenerErrorCode = 2 // Short URL already exists. // The uniqueness of a short URL is represented by code or short URL. URLShortenerErrorCode_ALREADY_EXISTS URLShortenerErrorCode = 3 // URL not found in system. URLShortenerErrorCode_NOT_FOUND URLShortenerErrorCode = 4 )
func (URLShortenerErrorCode) Descriptor ¶
func (URLShortenerErrorCode) Descriptor() protoreflect.EnumDescriptor
func (URLShortenerErrorCode) Enum ¶
func (x URLShortenerErrorCode) Enum() *URLShortenerErrorCode
func (URLShortenerErrorCode) EnumDescriptor
deprecated
func (URLShortenerErrorCode) EnumDescriptor() ([]byte, []int)
Deprecated: Use URLShortenerErrorCode.Descriptor instead.
func (URLShortenerErrorCode) Number ¶
func (x URLShortenerErrorCode) Number() protoreflect.EnumNumber
func (URLShortenerErrorCode) String ¶
func (x URLShortenerErrorCode) String() string
func (URLShortenerErrorCode) Type ¶
func (URLShortenerErrorCode) Type() protoreflect.EnumType
type URLShortenerServiceClient ¶
type URLShortenerServiceClient interface { CreateShortURL(ctx context.Context, in *CreateShortURLRequest, opts ...grpc.CallOption) (*CreateShortURLResponse, error) GetAllURL(ctx context.Context, in *GetAllURLRequest, opts ...grpc.CallOption) (*GetAllURLResponse, error) StreamAllURL(ctx context.Context, in *StreamAllURLRequest, opts ...grpc.CallOption) (URLShortenerService_StreamAllURLClient, error) GetURLDetail(ctx context.Context, in *GetURLDetailRequest, opts ...grpc.CallOption) (*GetURLDetailResponse, error) }
URLShortenerServiceClient is the client API for URLShortenerService 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 NewURLShortenerServiceClient ¶
func NewURLShortenerServiceClient(cc grpc.ClientConnInterface) URLShortenerServiceClient
type URLShortenerServiceServer ¶
type URLShortenerServiceServer interface { CreateShortURL(context.Context, *CreateShortURLRequest) (*CreateShortURLResponse, error) GetAllURL(context.Context, *GetAllURLRequest) (*GetAllURLResponse, error) StreamAllURL(*StreamAllURLRequest, URLShortenerService_StreamAllURLServer) error GetURLDetail(context.Context, *GetURLDetailRequest) (*GetURLDetailResponse, error) // contains filtered or unexported methods }
URLShortenerServiceServer is the server API for URLShortenerService service. All implementations must embed UnimplementedURLShortenerServiceServer for forward compatibility
type URLShortenerService_StreamAllURLClient ¶
type URLShortenerService_StreamAllURLClient interface { Recv() (*StreamAllURLResponse, error) grpc.ClientStream }
type URLShortenerService_StreamAllURLServer ¶
type URLShortenerService_StreamAllURLServer interface { Send(*StreamAllURLResponse) error grpc.ServerStream }
type UnimplementedURLShortenerServiceServer ¶
type UnimplementedURLShortenerServiceServer struct { }
UnimplementedURLShortenerServiceServer must be embedded to have forward compatible implementations.
func (UnimplementedURLShortenerServiceServer) CreateShortURL ¶
func (UnimplementedURLShortenerServiceServer) CreateShortURL(context.Context, *CreateShortURLRequest) (*CreateShortURLResponse, error)
func (UnimplementedURLShortenerServiceServer) GetAllURL ¶
func (UnimplementedURLShortenerServiceServer) GetAllURL(context.Context, *GetAllURLRequest) (*GetAllURLResponse, error)
func (UnimplementedURLShortenerServiceServer) GetURLDetail ¶
func (UnimplementedURLShortenerServiceServer) GetURLDetail(context.Context, *GetURLDetailRequest) (*GetURLDetailResponse, error)
func (UnimplementedURLShortenerServiceServer) StreamAllURL ¶
func (UnimplementedURLShortenerServiceServer) StreamAllURL(*StreamAllURLRequest, URLShortenerService_StreamAllURLServer) 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.