Skip to content

Instantly share code, notes, and snippets.

@gozeon
Created January 25, 2019 03:04
Show Gist options
  • Save gozeon/e493fe177c1cc454f71cceebd5d6a46c to your computer and use it in GitHub Desktop.
Save gozeon/e493fe177c1cc454f71cceebd5d6a46c to your computer and use it in GitHub Desktop.
use beaver with vscode-restclient
@baseUrl = http://127.0.0.1:8081
@X-AUTH-TOKEN = sWUhHRcs4Aqa0MEnYwbuQln3EW8CZ0oD
@appPrefix = app
@appName = goze
@channelName = app_channel
@clientID = 88133b00-0f0c-4320-9b39-840c65a532f0
### create app name
POST {{baseUrl}}/api/config HTTP/1.1
content-type: application/json
X-AUTH-TOKEN: {{X-AUTH-TOKEN}}
{
"key": "{{appPrefix}}",
"value": "{{appName}}"
}
### get app name info
GET {{baseUrl}}/api/config/{{appPrefix}} HTTP/1.1
content-type: application/json
X-AUTH-TOKEN: {{X-AUTH-TOKEN}}
### update app name info
PUT {{baseUrl}}/api/config/{{appPrefix}} HTTP/1.1
content-type: application/json
X-AUTH-TOKEN: {{X-AUTH-TOKEN}}
{
"value": "Beaver"
}
### del app name
DELETE {{baseUrl}}/api/config/{{appPrefix}} HTTP/1.1
content-type: application/json
X-AUTH-TOKEN: {{X-AUTH-TOKEN}}
### create channel
POST {{baseUrl}}/api/channel HTTP/1.1
content-type: application/json
X-AUTH-TOKEN: {{X-AUTH-TOKEN}}
{
"name": "{{channelName}}",
"type": "public"
}
### get channel info
GET {{baseUrl}}/api/channel/{{channelName}} HTTP/1.1
content-type: application/json
X-AUTH-TOKEN: {{X-AUTH-TOKEN}}
### update channel info
PUT {{baseUrl}}/api/channel/{{channelName}} HTTP/1.1
content-type: application/json
X-AUTH-TOKEN: {{X-AUTH-TOKEN}}
{
"type": "private"
}
### del channel
DELETE {{baseUrl}}/api/channel/{{channelName}} HTTP/1.1
content-type: application/json
X-AUTH-TOKEN: {{X-AUTH-TOKEN}}
### create client
POST {{baseUrl}}/api/client HTTP/1.1
content-type: application/json
X-AUTH-TOKEN: {{X-AUTH-TOKEN}}
{
"channels": ["{{channelName}}"]
}
### get client info
GET {{baseUrl}}/api/client/{{clientID}} HTTP/1.1
content-type: application/json
X-AUTH-TOKEN: {{X-AUTH-TOKEN}}
### cubscribe
PUT {{baseUrl}}/api/client/{{clientID}}/subscribe HTTP/1.1
content-type: application/json
X-AUTH-TOKEN: {{X-AUTH-TOKEN}}
{
"channel": "{{channelName}}"
}
### uncubscribe
PUT {{baseUrl}}/api/client/{{clientID}}/unsubscribe HTTP/1.1
content-type: application/json
X-AUTH-TOKEN: {{X-AUTH-TOKEN}}
{
"channel": "{{channelName}}"
}
### del client
DELETE {{baseUrl}}/api/client/{{clientID}} HTTP/1.1
content-type: application/json
X-AUTH-TOKEN: {{X-AUTH-TOKEN}}
#### publish message
POST {{baseUrl}}/api/publish HTTP/1.1
content-type: application/json
X-AUTH-TOKEN: {{X-AUTH-TOKEN}}
{
"channel": "{{channelName}}",
"data": "{\"message\": \"Hello World\"}"
}
#### broadcast message
POST {{baseUrl}}/api/broadcast HTTP/1.1
content-type: application/json
X-AUTH-TOKEN: {{X-AUTH-TOKEN}}
{
"channel": "{{channelName}}",
"data": "{\"message\": \"Hello World\"}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment