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:
@@ -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)
|
||||
}
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user