1 Star 0 Fork 0

bluesky2006 / wserver

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 702 Bytes
一键复制 编辑 原始数据 按行查看 历史
bluesky2006 提交于 2020-07-07 09:36 . demo for sql
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"time"
"github.com/alfred-zhong/wserver"
)
func main() {
pushURL := "http://127.0.0.1:12345/status"
contentType := "application/json"
pm := wserver.PushMessage{
UserID: "jack",
Event: "topic1",
Message: fmt.Sprintf("Hello in %s", time.Now().Format("2006-01-02 15:04:05.000")),
}
b, _ := json.Marshal(pm)
resp, err := http.DefaultClient.Post(pushURL, contentType, bytes.NewReader(b))
if err != nil {
fmt.Println(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
// handle error
fmt.Println(err)
}
fmt.Println(string(body))
time.Sleep(time.Second)
}
Go
1
https://gitee.com/bluesky2006/wserver.git
git@gitee.com:bluesky2006/wserver.git
bluesky2006
wserver
wserver
v1.1.0

搜索帮助