1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-01-23 17:53:05 +02:00
2021-10-12 12:55:53 +01:00

31 lines
681 B
Go

package main
import (
"context"
"log"
httpClient "github.com/asim/go-micro/plugins/client/http/v3"
"go-micro.dev/v4/client"
"go-micro.dev/v4/registry"
"go-micro.dev/v4/selector"
)
func main() {
CallHttpServer()
}
func CallHttpServer() {
r := registry.NewRegistry()
s := selector.NewSelector(selector.Registry(r))
// new client
c := httpClient.NewClient(client.Selector(s))
// create request/response
request := c.NewRequest("demo-http", "/demo", "", client.WithContentType("application/json"))
response := new(map[string]interface{})
// call service
err := c.Call(context.Background(), request, response)
log.Printf("err:%v response:%#v\n", err, response)
}