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