Example #1
0
func markdownCBQiniu(rw http.ResponseWriter, req *http.Request) {
	req.ParseForm()
	rawContent := req.Form.Get("rawContent")
	// fmt.Println(rawContent)
	fmt.Print(",")
	out := make([]byte, 0, 100)
	in := goutils.ToByte(rawContent)
	RPC_Client = rpcsv.RPCClient(rpc_tcp_server)
	err := rpcsv.Markdown(RPC_Client, &in, &out)
	if goutils.CheckErr(err) {
		rw.Write(goutils.ToByte(err.Error()))
		return
	}
	qiniuWriter.Reset()
	qiniuWriter.Write(goutils.ToByte("CallbackFunc(`"))
	data := make(map[string]interface{})
	data["MDContent"] = template.HTML(goutils.ToString(out))
	err = rpcsv.Theme.Execute(qiniuWriter, data)
	if goutils.CheckErr(err) {
		rw.Write(goutils.ToByte(err.Error()))
	}
	qiniuWriter.Write(goutils.ToByte("`)"))
	rw.Write(qiniuWriter.Bytes())
	writeCrossDomainHeaders(rw, req)
}
Example #2
0
func connect() {
	RPC_Client = rpcsv.RPCClient(rpc_tcp_server)
	go func() {
		time.Sleep(2e9)
		RPC_Client.Close()
	}()
}
Example #3
0
// 是否重新开始循环
func checkNilThenReLoop(clt *rpc.Client, reconnect bool) (bool, *rpc.Client) {
	if clt == nil || reconnect {
		clt = rpcsv.RPCClient(rpc_tcp_server)
		return true, clt
	}
	return false, clt
}
Example #4
0
func init() {
	var err error
	// if lis, err = rpcsv.RPCServe("88"); err != nil {
	// 	return
	// }
	exc_cmd = exc.NewCMD("ls").Debug()
	// rpc_client = rpcsv.RPCClient("127.0.0.1:88")
	rpc_client = rpcsv.RPCClient("tcphub.t0.daoapp.io:61142")
	if rpc_client == nil {
		// lis.Close()
		panic("rpc_client is nil!")
	}
	tpl, err = template.ParseFiles("theme.thm")
	if goutils.CheckErr(err) {
		panic("theme error")
	}
}
Example #5
0
func markdown(rw http.ResponseWriter, req *http.Request) {
	req.ParseForm()
	rawContent := req.Form.Get("rawContent")
	fmt.Println(req.RemoteAddr, req.Referer())
	// fmt.Println(rawContent)
	out := make([]byte, 0, 100)
	in := goutils.ToByte(rawContent)
	RPC_Client = rpcsv.RPCClient(rpc_tcp_server)
	err := rpcsv.Markdown(RPC_Client, &in, &out)
	if goutils.CheckErr(err) {
		rw.Write(goutils.ToByte(err.Error()))
		return
	}
	if len(out) <= 0 {
		rw.Write(goutils.ToByte("{response:nil}"))
		return
	}
	writeCrossDomainHeaders(rw, req)
	rw.Write(out)
}
Example #6
0
func connect() *rpc.Client {
	return rpcsv.RPCClient(rpc_tcp_server)
}