2022-03-09 23:21:04 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2022-03-07 14:45:54 +00:00
2022-02-28 16:17:11 +00:00
2022-02-18 20:39:45 +00:00
2022-01-12 10:03:46 +00:00
2022-02-24 16:11:57 +00:00
2021-11-18 08:33:36 +00:00
2021-10-28 12:08:20 +01:00
2022-02-20 12:36:15 +00:00
2022-02-24 22:04:39 +00:00
2022-02-28 17:55:46 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2022-01-26 13:06:45 +00:00
2022-02-19 18:01:25 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2022-03-09 23:21:04 +00:00
2022-02-11 14:27:47 +00:00
2021-12-29 13:41:36 +00:00
2022-03-03 14:24:45 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2022-02-20 12:02:04 +00:00
2021-12-29 13:41:36 +00:00
2022-02-20 21:44:00 +00:00
2022-02-20 22:12:44 +00:00
2022-02-14 15:40:49 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2022-03-09 17:00:50 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2022-03-02 17:15:22 +00:00
2022-02-14 15:40:49 +00:00
2022-02-15 17:32:16 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2022-02-21 13:22:08 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2022-02-21 14:54:04 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2022-03-01 09:15:35 +00:00
2021-12-29 13:41:36 +00:00
2021-12-29 13:41:36 +00:00
2022-03-01 17:03:04 +00:00
2022-02-16 09:26:30 +00:00
2022-02-16 21:45:47 +00:00
2022-02-21 16:54:05 +00:00
2022-02-28 16:17:11 +00:00
2021-10-28 14:58:32 +01:00
2021-04-21 16:05:08 +01:00
2020-07-28 14:57:55 +01:00
2022-03-02 10:16:25 +00:00
2022-03-07 13:02:11 +01:00

Discord Banner


M3O Go Client godoc Go Report Card Apache 2.0 License

This is the Go client to access APIs on the M3O Platform

Usage

Call a service using the generated client. Populate the M3O_API_TOKEN environment variable.

Import the package and initialise the service with your API token.

package main

import(
        "fmt"
        "os"

        "go.m3o.com/helloworld"
)

// Call returns a personalised "Hello $name" response
func main() {
        helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
        rsp, err := helloworldService.Call(&helloworld.CallRequest{
                Name: "John",

        })
        fmt.Println(rsp, err)
}

Generic Client

The generic client enables you to call any endpoint by name with freeform request/response types.

package main

import (
    "fmt"
    "os"

    "go.m3o.com/client"
)

type Request struct {
	Name string `json:"name"`
}

type Response struct {
	Msg string `json:"msg"`
}

var (
	token, _ = os.Getenv("TOKEN")
)

func main() {
	c := client.NewClient(nil)

	// set your api token
	c.SetToken(token)

   	req := &Request{
		Name: "John",
	}
	
	var rsp Response

	if err := c.Call("helloworld", "call", req, &rsp); err != nil {
		fmt.Println(err)
		return
	}
	
	fmt.Println(rsp)
}

Streaming

The client supports streaming but is not yet code generated. Use the following for streaming endpoints.

package main

import (
	"fmt"

	"go.m3o.com/client"
)

type Request struct {
	Count string `json:"count"`
}

type Response struct {
	Count string `json:"count"`
}

var (
	token, _ = os.Getenv("TOKEN")
)

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
	}

	for {
		var rsp Response
		if err := stream.Recv(&rsp); err != nil {
			fmt.Println(err)
			return
		}
		fmt.Println("got", rsp.Count)
	}
}
Description
No description provided
Readme 2 MiB
Languages
Go 100%