mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-16 13:04:34 +00:00
Commit from GitHub Actions (Generate Clients & Examples)
This commit is contained in:
6
examples/event/subscribe/curl/subscribeToATopic.sh
Executable file
6
examples/event/subscribe/curl/subscribeToATopic.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
curl "https://api.m3o.com/v1/event/Subscribe" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"topic": "user"
|
||||
}'
|
||||
17
examples/event/subscribe/go/subscribeToATopic.go
Executable file
17
examples/event/subscribe/go/subscribeToATopic.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/micro/services/clients/go/event"
|
||||
)
|
||||
|
||||
// Subscribe to messages for a given topic.
|
||||
func SubscribeToAtopic() {
|
||||
eventService := event.NewEventService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := eventService.Subscribe(&event.SubscribeRequest{
|
||||
Topic: "user",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
12
examples/event/subscribe/node/subscribeToATopic.js
Executable file
12
examples/event/subscribe/node/subscribeToATopic.js
Executable file
@@ -0,0 +1,12 @@
|
||||
const { EventService } = require("m3o/event");
|
||||
|
||||
// Subscribe to messages for a given topic.
|
||||
async function subscribeToAtopic() {
|
||||
let eventService = new EventService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await eventService.subscribe({
|
||||
topic: "user",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
subscribeToAtopic();
|
||||
Reference in New Issue
Block a user