mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-11 18:44:26 +00:00
Merge branch 'master' of ssh://github.com/m3o/m3o-go
This commit is contained in:
33
README.md
33
README.md
@@ -1,6 +1,8 @@
|
||||
# M3O Go Client
|
||||
|
||||
By default the client connects to api.m3o.com/client
|
||||
This is the Go client to access APIs on the M3O Platform
|
||||
|
||||
## Usage
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -33,28 +35,18 @@ func main() {
|
||||
req := &Request{
|
||||
Name: "John",
|
||||
}
|
||||
|
||||
var rsp Response
|
||||
|
||||
if err := c.Call("greeter", "Say.Hello", req, &rsp); err != nil {
|
||||
if err := c.Call("helloworld", "call", req, &rsp); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(rsp)
|
||||
}
|
||||
```
|
||||
|
||||
If you want to access your local micro:
|
||||
|
||||
```go
|
||||
c := client.NewClient(client.Options{Local: true})
|
||||
```
|
||||
|
||||
You can also set the api address explicitly:
|
||||
|
||||
```go
|
||||
c := client.NewClient(client.Options{Address: "https://api.yourdomain.com/client"})
|
||||
```
|
||||
|
||||
## Streaming
|
||||
|
||||
The client supports streaming
|
||||
@@ -76,10 +68,17 @@ type Response struct {
|
||||
Count string `json:"count"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
c := client.NewClient(&client.Options{Local: true})
|
||||
var (
|
||||
token, _ = os.Getenv("TOKEN")
|
||||
)
|
||||
|
||||
stream, err := c.Stream("example", "Streamer.ServerStream", Request{Count: "10"})
|
||||
func main() {
|
||||
c := client.NewClient(nil)
|
||||
|
||||
// set your api token
|
||||
c.SetToken(token)
|
||||
|
||||
stream, err := c.Stream("streams", "subscribe", Request{Count: "10"})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user