This commit is contained in:
Janos Dobronszki
2021-05-17 15:01:22 +01:00
committed by GitHub
parent a2dc68b385
commit 114fa6735b
8 changed files with 93 additions and 99 deletions

2
url/.gitignore vendored
View File

@@ -1,2 +1,2 @@
url-shortener
url

View File

@@ -1,3 +1,3 @@
FROM alpine
ADD url-shortener /url-shortener
ENTRYPOINT [ "/url-shortener" ]
ADD url /url
ENTRYPOINT [ "/url" ]

View File

@@ -23,7 +23,7 @@ type Url struct {
func NewUrl() *Url {
var hp string
cfg, err := config.Get("micro.url_shortener.host_prefix")
cfg, err := config.Get("micro.url.host_prefix")
if err != nil {
hp = cfg.String(hostPrefix)
}

View File

@@ -11,12 +11,12 @@ import (
func main() {
// Create service
srv := service.New(
service.Name("url-shortener"),
service.Name("url"),
service.Version("latest"),
)
// Register handler
pb.RegisterUrlShortenerHandler(srv.Server(), handler.NewUrl())
pb.RegisterUrlHandler(srv.Server(), handler.NewUrl())
// Run service
if err := srv.Run(); err != nil {

View File

@@ -1 +1 @@
service url-shortener
service url

View File

@@ -4,7 +4,7 @@
// protoc v3.6.1
// source: proto/url.proto
package urlshortener
package url
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
@@ -360,50 +360,44 @@ var File_proto_url_proto protoreflect.FileDescriptor
var file_proto_url_proto_rawDesc = []byte{
0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x75, 0x72, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x12, 0x0c, 0x75, 0x72, 0x6c, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x22,
0x38, 0x0a, 0x0e, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x26, 0x0a, 0x0e, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x55, 0x52, 0x4c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x64, 0x65, 0x73, 0x74, 0x69,
0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x52, 0x4c, 0x22, 0x2d, 0x0a, 0x0f, 0x53, 0x68, 0x6f,
0x72, 0x74, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08,
0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x22, 0x63, 0x0a, 0x07, 0x55, 0x52, 0x4c, 0x50,
0x61, 0x69, 0x72, 0x12, 0x26, 0x0a, 0x0e, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x55, 0x52, 0x4c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x64, 0x65, 0x73,
0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x52, 0x4c, 0x12, 0x1a, 0x0a, 0x08, 0x73,
0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73,
0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72,
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x22, 0x0d, 0x0a,
0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x41, 0x0a, 0x0c,
0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x31, 0x0a, 0x08,
0x75, 0x72, 0x6c, 0x50, 0x61, 0x69, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15,
0x2e, 0x75, 0x72, 0x6c, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x2e, 0x55, 0x52,
0x4c, 0x50, 0x61, 0x69, 0x72, 0x52, 0x08, 0x75, 0x72, 0x6c, 0x50, 0x61, 0x69, 0x72, 0x73, 0x22,
0x2a, 0x0a, 0x0c, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
0x1a, 0x0a, 0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x22, 0x37, 0x0a, 0x0d, 0x50,
0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x0e,
0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x52, 0x4c, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x55, 0x52, 0x4c, 0x32, 0xdd, 0x01, 0x0a, 0x0c, 0x55, 0x72, 0x6c, 0x53, 0x68, 0x6f, 0x72,
0x74, 0x65, 0x6e, 0x65, 0x72, 0x12, 0x48, 0x0a, 0x07, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e,
0x12, 0x1c, 0x2e, 0x75, 0x72, 0x6c, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x2e,
0x53, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d,
0x2e, 0x75, 0x72, 0x6c, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x2e, 0x53, 0x68,
0x6f, 0x72, 0x74, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
0x3f, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x19, 0x2e, 0x75, 0x72, 0x6c, 0x73, 0x68, 0x6f,
0x72, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x75, 0x72, 0x6c, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e, 0x65,
0x72, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
0x12, 0x42, 0x0a, 0x05, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x1a, 0x2e, 0x75, 0x72, 0x6c, 0x73,
0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x75, 0x72, 0x6c, 0x73, 0x68, 0x6f, 0x72, 0x74,
0x65, 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x22, 0x00, 0x42, 0x3c, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
0x6f, 0x6d, 0x2f, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x73, 0x2f, 0x75, 0x72, 0x6c, 0x2d, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x2f,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x75, 0x72, 0x6c, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e,
0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x6f, 0x12, 0x03, 0x75, 0x72, 0x6c, 0x22, 0x38, 0x0a, 0x0e, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x65,
0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x64, 0x65, 0x73, 0x74,
0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x52, 0x4c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x0e, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x52, 0x4c,
0x22, 0x2d, 0x0a, 0x0f, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x22,
0x63, 0x0a, 0x07, 0x55, 0x52, 0x4c, 0x50, 0x61, 0x69, 0x72, 0x12, 0x26, 0x0a, 0x0e, 0x64, 0x65,
0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x52, 0x4c, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0e, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55,
0x52, 0x4c, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x12, 0x14,
0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f,
0x77, 0x6e, 0x65, 0x72, 0x22, 0x0d, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x22, 0x38, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x75, 0x72, 0x6c, 0x50, 0x61, 0x69, 0x72, 0x73, 0x18,
0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x75, 0x72, 0x6c, 0x2e, 0x55, 0x52, 0x4c, 0x50,
0x61, 0x69, 0x72, 0x52, 0x08, 0x75, 0x72, 0x6c, 0x50, 0x61, 0x69, 0x72, 0x73, 0x22, 0x2a, 0x0a,
0x0c, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a,
0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x22, 0x37, 0x0a, 0x0d, 0x50, 0x72, 0x6f,
0x78, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x0e, 0x64, 0x65,
0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x52, 0x4c, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0e, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55,
0x52, 0x4c, 0x32, 0x9e, 0x01, 0x0a, 0x03, 0x55, 0x72, 0x6c, 0x12, 0x36, 0x0a, 0x07, 0x53, 0x68,
0x6f, 0x72, 0x74, 0x65, 0x6e, 0x12, 0x13, 0x2e, 0x75, 0x72, 0x6c, 0x2e, 0x53, 0x68, 0x6f, 0x72,
0x74, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x75, 0x72, 0x6c,
0x2e, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x12, 0x2d, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x10, 0x2e, 0x75, 0x72, 0x6c,
0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x75,
0x72, 0x6c, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
0x00, 0x12, 0x30, 0x0a, 0x05, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x11, 0x2e, 0x75, 0x72, 0x6c,
0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e,
0x75, 0x72, 0x6c, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x22, 0x00, 0x42, 0x29, 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
0x6d, 0x2f, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73,
0x2f, 0x75, 0x72, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x75, 0x72, 0x6c, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -420,22 +414,22 @@ func file_proto_url_proto_rawDescGZIP() []byte {
var file_proto_url_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_proto_url_proto_goTypes = []interface{}{
(*ShortenRequest)(nil), // 0: urlshortener.ShortenRequest
(*ShortenResponse)(nil), // 1: urlshortener.ShortenResponse
(*URLPair)(nil), // 2: urlshortener.URLPair
(*ListRequest)(nil), // 3: urlshortener.ListRequest
(*ListResponse)(nil), // 4: urlshortener.ListResponse
(*ProxyRequest)(nil), // 5: urlshortener.ProxyRequest
(*ProxyResponse)(nil), // 6: urlshortener.ProxyResponse
(*ShortenRequest)(nil), // 0: url.ShortenRequest
(*ShortenResponse)(nil), // 1: url.ShortenResponse
(*URLPair)(nil), // 2: url.URLPair
(*ListRequest)(nil), // 3: url.ListRequest
(*ListResponse)(nil), // 4: url.ListResponse
(*ProxyRequest)(nil), // 5: url.ProxyRequest
(*ProxyResponse)(nil), // 6: url.ProxyResponse
}
var file_proto_url_proto_depIdxs = []int32{
2, // 0: urlshortener.ListResponse.urlPairs:type_name -> urlshortener.URLPair
0, // 1: urlshortener.UrlShortener.Shorten:input_type -> urlshortener.ShortenRequest
3, // 2: urlshortener.UrlShortener.List:input_type -> urlshortener.ListRequest
5, // 3: urlshortener.UrlShortener.Proxy:input_type -> urlshortener.ProxyRequest
1, // 4: urlshortener.UrlShortener.Shorten:output_type -> urlshortener.ShortenResponse
4, // 5: urlshortener.UrlShortener.List:output_type -> urlshortener.ListResponse
6, // 6: urlshortener.UrlShortener.Proxy:output_type -> urlshortener.ProxyResponse
2, // 0: url.ListResponse.urlPairs:type_name -> url.URLPair
0, // 1: url.Url.Shorten:input_type -> url.ShortenRequest
3, // 2: url.Url.List:input_type -> url.ListRequest
5, // 3: url.Url.Proxy:input_type -> url.ProxyRequest
1, // 4: url.Url.Shorten:output_type -> url.ShortenResponse
4, // 5: url.Url.List:output_type -> url.ListResponse
6, // 6: url.Url.Proxy:output_type -> url.ProxyResponse
4, // [4:7] is the sub-list for method output_type
1, // [1:4] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: proto/url.proto
package urlshortener
package url
import (
fmt "fmt"
@@ -33,34 +33,34 @@ var _ context.Context
var _ client.Option
var _ server.Option
// Api Endpoints for UrlShortener service
// Api Endpoints for Url service
func NewUrlShortenerEndpoints() []*api.Endpoint {
func NewUrlEndpoints() []*api.Endpoint {
return []*api.Endpoint{}
}
// Client API for UrlShortener service
// Client API for Url service
type UrlShortenerService interface {
type UrlService interface {
Shorten(ctx context.Context, in *ShortenRequest, opts ...client.CallOption) (*ShortenResponse, error)
List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error)
Proxy(ctx context.Context, in *ProxyRequest, opts ...client.CallOption) (*ProxyResponse, error)
}
type urlShortenerService struct {
type urlService struct {
c client.Client
name string
}
func NewUrlShortenerService(name string, c client.Client) UrlShortenerService {
return &urlShortenerService{
func NewUrlService(name string, c client.Client) UrlService {
return &urlService{
c: c,
name: name,
}
}
func (c *urlShortenerService) Shorten(ctx context.Context, in *ShortenRequest, opts ...client.CallOption) (*ShortenResponse, error) {
req := c.c.NewRequest(c.name, "UrlShortener.Shorten", in)
func (c *urlService) Shorten(ctx context.Context, in *ShortenRequest, opts ...client.CallOption) (*ShortenResponse, error) {
req := c.c.NewRequest(c.name, "Url.Shorten", in)
out := new(ShortenResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
@@ -69,8 +69,8 @@ func (c *urlShortenerService) Shorten(ctx context.Context, in *ShortenRequest, o
return out, nil
}
func (c *urlShortenerService) List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) {
req := c.c.NewRequest(c.name, "UrlShortener.List", in)
func (c *urlService) List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) {
req := c.c.NewRequest(c.name, "Url.List", in)
out := new(ListResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
@@ -79,8 +79,8 @@ func (c *urlShortenerService) List(ctx context.Context, in *ListRequest, opts ..
return out, nil
}
func (c *urlShortenerService) Proxy(ctx context.Context, in *ProxyRequest, opts ...client.CallOption) (*ProxyResponse, error) {
req := c.c.NewRequest(c.name, "UrlShortener.Proxy", in)
func (c *urlService) Proxy(ctx context.Context, in *ProxyRequest, opts ...client.CallOption) (*ProxyResponse, error) {
req := c.c.NewRequest(c.name, "Url.Proxy", in)
out := new(ProxyResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
@@ -89,39 +89,39 @@ func (c *urlShortenerService) Proxy(ctx context.Context, in *ProxyRequest, opts
return out, nil
}
// Server API for UrlShortener service
// Server API for Url service
type UrlShortenerHandler interface {
type UrlHandler interface {
Shorten(context.Context, *ShortenRequest, *ShortenResponse) error
List(context.Context, *ListRequest, *ListResponse) error
Proxy(context.Context, *ProxyRequest, *ProxyResponse) error
}
func RegisterUrlShortenerHandler(s server.Server, hdlr UrlShortenerHandler, opts ...server.HandlerOption) error {
type urlShortener interface {
func RegisterUrlHandler(s server.Server, hdlr UrlHandler, opts ...server.HandlerOption) error {
type url interface {
Shorten(ctx context.Context, in *ShortenRequest, out *ShortenResponse) error
List(ctx context.Context, in *ListRequest, out *ListResponse) error
Proxy(ctx context.Context, in *ProxyRequest, out *ProxyResponse) error
}
type UrlShortener struct {
urlShortener
type Url struct {
url
}
h := &urlShortenerHandler{hdlr}
return s.Handle(s.NewHandler(&UrlShortener{h}, opts...))
h := &urlHandler{hdlr}
return s.Handle(s.NewHandler(&Url{h}, opts...))
}
type urlShortenerHandler struct {
UrlShortenerHandler
type urlHandler struct {
UrlHandler
}
func (h *urlShortenerHandler) Shorten(ctx context.Context, in *ShortenRequest, out *ShortenResponse) error {
return h.UrlShortenerHandler.Shorten(ctx, in, out)
func (h *urlHandler) Shorten(ctx context.Context, in *ShortenRequest, out *ShortenResponse) error {
return h.UrlHandler.Shorten(ctx, in, out)
}
func (h *urlShortenerHandler) List(ctx context.Context, in *ListRequest, out *ListResponse) error {
return h.UrlShortenerHandler.List(ctx, in, out)
func (h *urlHandler) List(ctx context.Context, in *ListRequest, out *ListResponse) error {
return h.UrlHandler.List(ctx, in, out)
}
func (h *urlShortenerHandler) Proxy(ctx context.Context, in *ProxyRequest, out *ProxyResponse) error {
return h.UrlShortenerHandler.Proxy(ctx, in, out)
func (h *urlHandler) Proxy(ctx context.Context, in *ProxyRequest, out *ProxyResponse) error {
return h.UrlHandler.Proxy(ctx, in, out)
}

View File

@@ -1,10 +1,10 @@
syntax = "proto3";
package urlshortener;
package url;
option go_package = "github.com/micro/services/url-shortener/proto;urlshortener";
option go_package = "github.com/micro/services/url/proto;url";
service UrlShortener {
service Url {
rpc Shorten(ShortenRequest) returns (ShortenResponse) {}
rpc List(ListRequest) returns (ListResponse) {}
rpc Proxy(ProxyRequest) returns (ProxyResponse) {}