use own fork

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-01-10 14:48:10 +03:00
parent 280d3a64c9
commit 59d77f7b8c
22 changed files with 812 additions and 866 deletions

View File

@@ -1,18 +1,18 @@
# HTTP Client
This plugin is a http client for go-micro.
This plugin is a http client for micro.
## Overview
The http client wraps `net/http` to provide a robust go-micro client with service discovery, load balancing and streaming.
It complies with the [go-micro.Client](https://godoc.org/github.com/micro/go-micro/client#Client) interface.
The http client wraps `net/http` to provide a robust micro client with service discovery, load balancing and streaming.
It complies with the [micro.Client](https://godoc.org/github.com/unistack-org/micro-client-http#Client) interface.
## Usage
### Use directly
```go
import "github.com/micro/go-plugins/client/http"
import "github.com/unistack-org/micro-client-http"
service := micro.NewService(
micro.Name("my.service"),
@@ -20,16 +20,6 @@ service := micro.NewService(
)
```
### Use with flags
```go
import _ "github.com/micro/go-plugins/client/http"
```
```shell
go run main.go --client=http
```
### Call Service
Assuming you have a http service "my.service" with path "/foo/bar"
@@ -45,6 +35,17 @@ response := new(protoResponse)
err := client.Call(context.TODO(), request, response)
```
or you can call any rest api or site and unmarshal to response struct
```go
// new client
client := client.NewClientCallOptions(http.NewClient(), http.Address("https://api.github.com"))
req := client.NewRequest("github", "/users/vtolstov", nil)
rsp := make(map[string]interface{})
err := c.Call(context.TODO(), req, &rsp, mhttp.Method(http.MethodGet))
```
Look at http_test.go for detailed use.
### Encoding