1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-11-29 21:47:44 +02:00

examples at v3

This commit is contained in:
Asim Aslam
2021-01-20 21:28:48 +00:00
parent dc8236ec05
commit 8e3b7a57d9
234 changed files with 326 additions and 12243 deletions

View File

@@ -1,40 +0,0 @@
package main
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"github.com/golang/protobuf/proto"
api "github.com/micro/micro/v2/api/proto"
)
func main() {
req, err := proto.Marshal(&api.Request{Get: map[string]*api.Pair{"name": {Key: "name", Values: []string{"John"}}}})
if err != nil {
fmt.Println(err)
return
}
r, err := http.Post("http://localhost:8080/greeter/say/hello", "application/protobuf", bytes.NewReader(req))
if err != nil {
fmt.Println(err)
return
}
defer r.Body.Close()
b, err := ioutil.ReadAll(r.Body)
if err != nil {
fmt.Println(err)
return
}
rsp := &api.Response{}
if err := proto.Unmarshal(b, rsp); err != nil {
fmt.Println(err)
return
}
fmt.Println(rsp.Body)
}

View File

@@ -4,7 +4,7 @@ import (
"context"
"fmt"
hello "github.com/micro/go-micro/examples/greeter/srv/proto/hello"
hello "github.com/asim/go-micro/examples/v3/greeter/srv/proto/hello"
"github.com/asim/go-micro/v3"
)

View File

@@ -7,7 +7,7 @@ import (
"net/http"
"github.com/golang/protobuf/proto"
hello "github.com/micro/go-micro/examples/greeter/srv/proto/hello"
hello "github.com/asim/go-micro/examples/v3/greeter/srv/proto/hello"
)
func main() {