mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-12 02:45:11 +00:00
Commit from m3o/m3o action
This commit is contained in:
@@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stream/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Subscribe
|
||||
|
||||
Subscribe to messages for a given topic.
|
||||
|
||||
|
||||
[https://m3o.com/stream/api#Subscribe](https://m3o.com/stream/api#Subscribe)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// Subscribe to messages for a given topic.
|
||||
func SubscribeToAtopic() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.Subscribe(&stream.SubscribeRequest{
|
||||
Topic: "events",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Publish
|
||||
|
||||
Publish a message to the stream. Specify a topic to group messages for a specific topic.
|
||||
@@ -36,30 +63,3 @@ Topic: "events",
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Subscribe
|
||||
|
||||
Subscribe to messages for a given topic.
|
||||
|
||||
|
||||
[https://m3o.com/stream/api#Subscribe](https://m3o.com/stream/api#Subscribe)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// Subscribe to messages for a given topic.
|
||||
func SubscribeToAtopic() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.Subscribe(&stream.SubscribeRequest{
|
||||
Topic: "events",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user