mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-19 05:55:19 +00:00
Commit from GitHub Actions (Generate Clients & Examples)
This commit is contained in:
11
examples/event/publish/curl/publishAMessage.sh
Executable file
11
examples/event/publish/curl/publishAMessage.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
curl "https://api.m3o.com/v1/event/Publish" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"message": {
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john"
|
||||
},
|
||||
"topic": "user"
|
||||
}'
|
||||
22
examples/event/publish/go/publishAMessage.go
Executable file
22
examples/event/publish/go/publishAMessage.go
Executable file
@@ -0,0 +1,22 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/micro/services/clients/go/event"
|
||||
)
|
||||
|
||||
// Publish a message to the event. Specify a topic to group messages for a specific topic.
|
||||
func PublishAmessage() {
|
||||
eventService := event.NewEventService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
},
|
||||
Topic: "user",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
17
examples/event/publish/node/publishAMessage.js
Executable file
17
examples/event/publish/node/publishAMessage.js
Executable file
@@ -0,0 +1,17 @@
|
||||
const { EventService } = require("m3o/event");
|
||||
|
||||
// Publish a message to the event. Specify a topic to group messages for a specific topic.
|
||||
async function publishAmessage() {
|
||||
let eventService = new EventService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await eventService.publish({
|
||||
message: {
|
||||
id: "1",
|
||||
type: "signup",
|
||||
user: "john",
|
||||
},
|
||||
topic: "user",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
publishAmessage();
|
||||
Reference in New Issue
Block a user