mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 19:04:35 +00:00
Fix url (#105)
This commit is contained in:
2
url/.gitignore
vendored
2
url/.gitignore
vendored
@@ -1,2 +1,2 @@
|
|||||||
|
|
||||||
url-shortener
|
url
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
FROM alpine
|
FROM alpine
|
||||||
ADD url-shortener /url-shortener
|
ADD url /url
|
||||||
ENTRYPOINT [ "/url-shortener" ]
|
ENTRYPOINT [ "/url" ]
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ type Url struct {
|
|||||||
|
|
||||||
func NewUrl() *Url {
|
func NewUrl() *Url {
|
||||||
var hp string
|
var hp string
|
||||||
cfg, err := config.Get("micro.url_shortener.host_prefix")
|
cfg, err := config.Get("micro.url.host_prefix")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hp = cfg.String(hostPrefix)
|
hp = cfg.String(hostPrefix)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
// Create service
|
// Create service
|
||||||
srv := service.New(
|
srv := service.New(
|
||||||
service.Name("url-shortener"),
|
service.Name("url"),
|
||||||
service.Version("latest"),
|
service.Version("latest"),
|
||||||
)
|
)
|
||||||
|
|
||||||
// Register handler
|
// Register handler
|
||||||
pb.RegisterUrlShortenerHandler(srv.Server(), handler.NewUrl())
|
pb.RegisterUrlHandler(srv.Server(), handler.NewUrl())
|
||||||
|
|
||||||
// Run service
|
// Run service
|
||||||
if err := srv.Run(); err != nil {
|
if err := srv.Run(); err != nil {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
service url-shortener
|
service url
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
// protoc v3.6.1
|
// protoc v3.6.1
|
||||||
// source: proto/url.proto
|
// source: proto/url.proto
|
||||||
|
|
||||||
package urlshortener
|
package url
|
||||||
|
|
||||||
import (
|
import (
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
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{
|
var file_proto_url_proto_rawDesc = []byte{
|
||||||
0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x75, 0x72, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
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,
|
0x6f, 0x12, 0x03, 0x75, 0x72, 0x6c, 0x22, 0x38, 0x0a, 0x0e, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x65,
|
||||||
0x38, 0x0a, 0x0e, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
|
0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x64, 0x65, 0x73, 0x74,
|
||||||
0x74, 0x12, 0x26, 0x0a, 0x0e, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x52, 0x4c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||||
0x55, 0x52, 0x4c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x64, 0x65, 0x73, 0x74, 0x69,
|
0x52, 0x0e, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x52, 0x4c,
|
||||||
0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x52, 0x4c, 0x22, 0x2d, 0x0a, 0x0f, 0x53, 0x68, 0x6f,
|
0x22, 0x2d, 0x0a, 0x0f, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f,
|
||||||
0x72, 0x74, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08,
|
0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x18,
|
||||||
0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
|
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x22,
|
||||||
0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x22, 0x63, 0x0a, 0x07, 0x55, 0x52, 0x4c, 0x50,
|
0x63, 0x0a, 0x07, 0x55, 0x52, 0x4c, 0x50, 0x61, 0x69, 0x72, 0x12, 0x26, 0x0a, 0x0e, 0x64, 0x65,
|
||||||
0x61, 0x69, 0x72, 0x12, 0x26, 0x0a, 0x0e, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69,
|
0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x52, 0x4c, 0x18, 0x01, 0x20, 0x01,
|
||||||
0x6f, 0x6e, 0x55, 0x52, 0x4c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x64, 0x65, 0x73,
|
0x28, 0x09, 0x52, 0x0e, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55,
|
||||||
0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x52, 0x4c, 0x12, 0x1a, 0x0a, 0x08, 0x73,
|
0x52, 0x4c, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x18, 0x02,
|
||||||
0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73,
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x12, 0x14,
|
||||||
0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72,
|
0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f,
|
||||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x22, 0x0d, 0x0a,
|
0x77, 0x6e, 0x65, 0x72, 0x22, 0x0d, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75,
|
||||||
0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x41, 0x0a, 0x0c,
|
0x65, 0x73, 0x74, 0x22, 0x38, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f,
|
||||||
0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x31, 0x0a, 0x08,
|
0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x75, 0x72, 0x6c, 0x50, 0x61, 0x69, 0x72, 0x73, 0x18,
|
||||||
0x75, 0x72, 0x6c, 0x50, 0x61, 0x69, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15,
|
0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x75, 0x72, 0x6c, 0x2e, 0x55, 0x52, 0x4c, 0x50,
|
||||||
0x2e, 0x75, 0x72, 0x6c, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x2e, 0x55, 0x52,
|
0x61, 0x69, 0x72, 0x52, 0x08, 0x75, 0x72, 0x6c, 0x50, 0x61, 0x69, 0x72, 0x73, 0x22, 0x2a, 0x0a,
|
||||||
0x4c, 0x50, 0x61, 0x69, 0x72, 0x52, 0x08, 0x75, 0x72, 0x6c, 0x50, 0x61, 0x69, 0x72, 0x73, 0x22,
|
0x0c, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a,
|
||||||
0x2a, 0x0a, 0x0c, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
|
0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||||
0x1a, 0x0a, 0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x18, 0x01, 0x20, 0x01, 0x28,
|
0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x22, 0x37, 0x0a, 0x0d, 0x50, 0x72, 0x6f,
|
||||||
0x09, 0x52, 0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x52, 0x4c, 0x22, 0x37, 0x0a, 0x0d, 0x50,
|
0x78, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x0e, 0x64, 0x65,
|
||||||
0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x0e,
|
0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x52, 0x4c, 0x18, 0x01, 0x20, 0x01,
|
||||||
0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x52, 0x4c, 0x18, 0x01,
|
0x28, 0x09, 0x52, 0x0e, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55,
|
||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f,
|
0x52, 0x4c, 0x32, 0x9e, 0x01, 0x0a, 0x03, 0x55, 0x72, 0x6c, 0x12, 0x36, 0x0a, 0x07, 0x53, 0x68,
|
||||||
0x6e, 0x55, 0x52, 0x4c, 0x32, 0xdd, 0x01, 0x0a, 0x0c, 0x55, 0x72, 0x6c, 0x53, 0x68, 0x6f, 0x72,
|
0x6f, 0x72, 0x74, 0x65, 0x6e, 0x12, 0x13, 0x2e, 0x75, 0x72, 0x6c, 0x2e, 0x53, 0x68, 0x6f, 0x72,
|
||||||
0x74, 0x65, 0x6e, 0x65, 0x72, 0x12, 0x48, 0x0a, 0x07, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e,
|
0x74, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x75, 0x72, 0x6c,
|
||||||
0x12, 0x1c, 0x2e, 0x75, 0x72, 0x6c, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x2e,
|
0x2e, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
||||||
0x53, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d,
|
0x22, 0x00, 0x12, 0x2d, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x10, 0x2e, 0x75, 0x72, 0x6c,
|
||||||
0x2e, 0x75, 0x72, 0x6c, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x2e, 0x53, 0x68,
|
0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x75,
|
||||||
0x6f, 0x72, 0x74, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
|
0x72, 0x6c, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
|
||||||
0x3f, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x19, 0x2e, 0x75, 0x72, 0x6c, 0x73, 0x68, 0x6f,
|
0x00, 0x12, 0x30, 0x0a, 0x05, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x11, 0x2e, 0x75, 0x72, 0x6c,
|
||||||
0x72, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65,
|
0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e,
|
||||||
0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x75, 0x72, 0x6c, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e, 0x65,
|
0x75, 0x72, 0x6c, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
||||||
0x72, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
|
0x65, 0x22, 0x00, 0x42, 0x29, 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
|
||||||
0x12, 0x42, 0x0a, 0x05, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x1a, 0x2e, 0x75, 0x72, 0x6c, 0x73,
|
0x6d, 0x2f, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73,
|
||||||
0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65,
|
0x2f, 0x75, 0x72, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x75, 0x72, 0x6c, 0x62, 0x06,
|
||||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x75, 0x72, 0x6c, 0x73, 0x68, 0x6f, 0x72, 0x74,
|
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
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,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
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_msgTypes = make([]protoimpl.MessageInfo, 7)
|
||||||
var file_proto_url_proto_goTypes = []interface{}{
|
var file_proto_url_proto_goTypes = []interface{}{
|
||||||
(*ShortenRequest)(nil), // 0: urlshortener.ShortenRequest
|
(*ShortenRequest)(nil), // 0: url.ShortenRequest
|
||||||
(*ShortenResponse)(nil), // 1: urlshortener.ShortenResponse
|
(*ShortenResponse)(nil), // 1: url.ShortenResponse
|
||||||
(*URLPair)(nil), // 2: urlshortener.URLPair
|
(*URLPair)(nil), // 2: url.URLPair
|
||||||
(*ListRequest)(nil), // 3: urlshortener.ListRequest
|
(*ListRequest)(nil), // 3: url.ListRequest
|
||||||
(*ListResponse)(nil), // 4: urlshortener.ListResponse
|
(*ListResponse)(nil), // 4: url.ListResponse
|
||||||
(*ProxyRequest)(nil), // 5: urlshortener.ProxyRequest
|
(*ProxyRequest)(nil), // 5: url.ProxyRequest
|
||||||
(*ProxyResponse)(nil), // 6: urlshortener.ProxyResponse
|
(*ProxyResponse)(nil), // 6: url.ProxyResponse
|
||||||
}
|
}
|
||||||
var file_proto_url_proto_depIdxs = []int32{
|
var file_proto_url_proto_depIdxs = []int32{
|
||||||
2, // 0: urlshortener.ListResponse.urlPairs:type_name -> urlshortener.URLPair
|
2, // 0: url.ListResponse.urlPairs:type_name -> url.URLPair
|
||||||
0, // 1: urlshortener.UrlShortener.Shorten:input_type -> urlshortener.ShortenRequest
|
0, // 1: url.Url.Shorten:input_type -> url.ShortenRequest
|
||||||
3, // 2: urlshortener.UrlShortener.List:input_type -> urlshortener.ListRequest
|
3, // 2: url.Url.List:input_type -> url.ListRequest
|
||||||
5, // 3: urlshortener.UrlShortener.Proxy:input_type -> urlshortener.ProxyRequest
|
5, // 3: url.Url.Proxy:input_type -> url.ProxyRequest
|
||||||
1, // 4: urlshortener.UrlShortener.Shorten:output_type -> urlshortener.ShortenResponse
|
1, // 4: url.Url.Shorten:output_type -> url.ShortenResponse
|
||||||
4, // 5: urlshortener.UrlShortener.List:output_type -> urlshortener.ListResponse
|
4, // 5: url.Url.List:output_type -> url.ListResponse
|
||||||
6, // 6: urlshortener.UrlShortener.Proxy:output_type -> urlshortener.ProxyResponse
|
6, // 6: url.Url.Proxy:output_type -> url.ProxyResponse
|
||||||
4, // [4:7] is the sub-list for method output_type
|
4, // [4:7] is the sub-list for method output_type
|
||||||
1, // [1:4] is the sub-list for method input_type
|
1, // [1:4] is the sub-list for method input_type
|
||||||
1, // [1:1] is the sub-list for extension type_name
|
1, // [1:1] is the sub-list for extension type_name
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
||||||
// source: proto/url.proto
|
// source: proto/url.proto
|
||||||
|
|
||||||
package urlshortener
|
package url
|
||||||
|
|
||||||
import (
|
import (
|
||||||
fmt "fmt"
|
fmt "fmt"
|
||||||
@@ -33,34 +33,34 @@ var _ context.Context
|
|||||||
var _ client.Option
|
var _ client.Option
|
||||||
var _ server.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{}
|
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)
|
Shorten(ctx context.Context, in *ShortenRequest, opts ...client.CallOption) (*ShortenResponse, error)
|
||||||
List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error)
|
List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error)
|
||||||
Proxy(ctx context.Context, in *ProxyRequest, opts ...client.CallOption) (*ProxyResponse, error)
|
Proxy(ctx context.Context, in *ProxyRequest, opts ...client.CallOption) (*ProxyResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type urlShortenerService struct {
|
type urlService struct {
|
||||||
c client.Client
|
c client.Client
|
||||||
name string
|
name string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUrlShortenerService(name string, c client.Client) UrlShortenerService {
|
func NewUrlService(name string, c client.Client) UrlService {
|
||||||
return &urlShortenerService{
|
return &urlService{
|
||||||
c: c,
|
c: c,
|
||||||
name: name,
|
name: name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *urlShortenerService) Shorten(ctx context.Context, in *ShortenRequest, opts ...client.CallOption) (*ShortenResponse, error) {
|
func (c *urlService) Shorten(ctx context.Context, in *ShortenRequest, opts ...client.CallOption) (*ShortenResponse, error) {
|
||||||
req := c.c.NewRequest(c.name, "UrlShortener.Shorten", in)
|
req := c.c.NewRequest(c.name, "Url.Shorten", in)
|
||||||
out := new(ShortenResponse)
|
out := new(ShortenResponse)
|
||||||
err := c.c.Call(ctx, req, out, opts...)
|
err := c.c.Call(ctx, req, out, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -69,8 +69,8 @@ func (c *urlShortenerService) Shorten(ctx context.Context, in *ShortenRequest, o
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *urlShortenerService) List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) {
|
func (c *urlService) List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) {
|
||||||
req := c.c.NewRequest(c.name, "UrlShortener.List", in)
|
req := c.c.NewRequest(c.name, "Url.List", in)
|
||||||
out := new(ListResponse)
|
out := new(ListResponse)
|
||||||
err := c.c.Call(ctx, req, out, opts...)
|
err := c.c.Call(ctx, req, out, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -79,8 +79,8 @@ func (c *urlShortenerService) List(ctx context.Context, in *ListRequest, opts ..
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *urlShortenerService) Proxy(ctx context.Context, in *ProxyRequest, opts ...client.CallOption) (*ProxyResponse, error) {
|
func (c *urlService) Proxy(ctx context.Context, in *ProxyRequest, opts ...client.CallOption) (*ProxyResponse, error) {
|
||||||
req := c.c.NewRequest(c.name, "UrlShortener.Proxy", in)
|
req := c.c.NewRequest(c.name, "Url.Proxy", in)
|
||||||
out := new(ProxyResponse)
|
out := new(ProxyResponse)
|
||||||
err := c.c.Call(ctx, req, out, opts...)
|
err := c.c.Call(ctx, req, out, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -89,39 +89,39 @@ func (c *urlShortenerService) Proxy(ctx context.Context, in *ProxyRequest, opts
|
|||||||
return out, nil
|
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
|
Shorten(context.Context, *ShortenRequest, *ShortenResponse) error
|
||||||
List(context.Context, *ListRequest, *ListResponse) error
|
List(context.Context, *ListRequest, *ListResponse) error
|
||||||
Proxy(context.Context, *ProxyRequest, *ProxyResponse) error
|
Proxy(context.Context, *ProxyRequest, *ProxyResponse) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterUrlShortenerHandler(s server.Server, hdlr UrlShortenerHandler, opts ...server.HandlerOption) error {
|
func RegisterUrlHandler(s server.Server, hdlr UrlHandler, opts ...server.HandlerOption) error {
|
||||||
type urlShortener interface {
|
type url interface {
|
||||||
Shorten(ctx context.Context, in *ShortenRequest, out *ShortenResponse) error
|
Shorten(ctx context.Context, in *ShortenRequest, out *ShortenResponse) error
|
||||||
List(ctx context.Context, in *ListRequest, out *ListResponse) error
|
List(ctx context.Context, in *ListRequest, out *ListResponse) error
|
||||||
Proxy(ctx context.Context, in *ProxyRequest, out *ProxyResponse) error
|
Proxy(ctx context.Context, in *ProxyRequest, out *ProxyResponse) error
|
||||||
}
|
}
|
||||||
type UrlShortener struct {
|
type Url struct {
|
||||||
urlShortener
|
url
|
||||||
}
|
}
|
||||||
h := &urlShortenerHandler{hdlr}
|
h := &urlHandler{hdlr}
|
||||||
return s.Handle(s.NewHandler(&UrlShortener{h}, opts...))
|
return s.Handle(s.NewHandler(&Url{h}, opts...))
|
||||||
}
|
}
|
||||||
|
|
||||||
type urlShortenerHandler struct {
|
type urlHandler struct {
|
||||||
UrlShortenerHandler
|
UrlHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *urlShortenerHandler) Shorten(ctx context.Context, in *ShortenRequest, out *ShortenResponse) error {
|
func (h *urlHandler) Shorten(ctx context.Context, in *ShortenRequest, out *ShortenResponse) error {
|
||||||
return h.UrlShortenerHandler.Shorten(ctx, in, out)
|
return h.UrlHandler.Shorten(ctx, in, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *urlShortenerHandler) List(ctx context.Context, in *ListRequest, out *ListResponse) error {
|
func (h *urlHandler) List(ctx context.Context, in *ListRequest, out *ListResponse) error {
|
||||||
return h.UrlShortenerHandler.List(ctx, in, out)
|
return h.UrlHandler.List(ctx, in, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *urlShortenerHandler) Proxy(ctx context.Context, in *ProxyRequest, out *ProxyResponse) error {
|
func (h *urlHandler) Proxy(ctx context.Context, in *ProxyRequest, out *ProxyResponse) error {
|
||||||
return h.UrlShortenerHandler.Proxy(ctx, in, out)
|
return h.UrlHandler.Proxy(ctx, in, out)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
syntax = "proto3";
|
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 Shorten(ShortenRequest) returns (ShortenResponse) {}
|
||||||
rpc List(ListRequest) returns (ListResponse) {}
|
rpc List(ListRequest) returns (ListResponse) {}
|
||||||
rpc Proxy(ProxyRequest) returns (ProxyResponse) {}
|
rpc Proxy(ProxyRequest) returns (ProxyResponse) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user