当前位置: 首页>>代码示例>>Golang>>正文


Golang httprpc.CallJson函数代码示例

本文整理汇总了Golang中github.com/kdar/httprpc.CallJson函数的典型用法代码示例。如果您正苦于以下问题:Golang CallJson函数的具体用法?Golang CallJson怎么用?Golang CallJson使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CallJson函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main

func main() {
	var reply Reply
	err := httprpc.CallJson("1.0", "http://localhost:9000/rpc", "HelloService.Say", &Args{"kevin"}, &reply)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(reply.Message)
}
开发者ID:NoahShen,项目名称:httprpc,代码行数:8,代码来源:client.go

示例2: PauseAll

func PauseAll() (string, error) {
	method := "aria2.pauseAll"
	paramArr := make([]string, 0)
	var reply string
	err := httprpc.CallJson(RpcVersion, RpcUrl, method, paramArr, &reply)
	if err != nil {
		return "", err
	}
	return reply, nil
}
开发者ID:ukd1,项目名称:aria2rpc,代码行数:10,代码来源:aria2rpc.go

示例3: GetGlobalStat

func GetGlobalStat() (map[string]interface{}, error) {
	method := "aria2.getGlobalStat"
	paramArr := make([]interface{}, 0)
	var reply = make(map[string]interface{})
	err := httprpc.CallJson(RpcVersion, RpcUrl, method, paramArr, &reply)
	if err != nil {
		return nil, err
	}
	return reply, nil
}
开发者ID:ukd1,项目名称:aria2rpc,代码行数:10,代码来源:aria2rpc.go

示例4: GetGlobalOption

func GetGlobalOption() (map[string]interface{}, error) {
	method := "aria2.getGlobalOption"
	paramArr := make([]interface{}, 1)
	paramArr[0] = "token:" + RpcSecret
	var reply = make(map[string]interface{})
	err := httprpc.CallJson(RpcVersion, RpcUrl, method, paramArr, &reply)
	if err != nil {
		return nil, err
	}
	return reply, nil
}
开发者ID:headzoo,项目名称:aria2rpc,代码行数:11,代码来源:aria2rpc.go

示例5: UnpauseAll

func UnpauseAll() (string, error) {
	method := "aria2.unpauseAll"
	paramArr := make([]string, 1)
	paramArr[0] = "token:" + RpcSecret
	var reply string
	err := httprpc.CallJson(RpcVersion, RpcUrl, method, paramArr, &reply)
	if err != nil {
		return "", err
	}
	return reply, nil
}
开发者ID:headzoo,项目名称:aria2rpc,代码行数:11,代码来源:aria2rpc.go

示例6: Unpause

func Unpause(gid string) (string, error) {
	method := "aria2.unpause"
	paramArr := make([]interface{}, 1)
	paramArr[0] = gid
	var replyGID string
	err := httprpc.CallJson(RpcVersion, RpcUrl, method, paramArr, &replyGID)
	if err != nil {
		return "", err
	}
	return replyGID, nil
}
开发者ID:ukd1,项目名称:aria2rpc,代码行数:11,代码来源:aria2rpc.go

示例7: ChangeGlobalOption

func ChangeGlobalOption(params map[string]string) (string, error) {
	method := "aria2.changeGlobalOption"
	paramArr := make([]interface{}, 0)
	paramArr = append(paramArr, params)

	var reply string
	err := httprpc.CallJson(RpcVersion, RpcUrl, method, paramArr, &reply)
	if err != nil {
		return "", err
	}
	return reply, nil
}
开发者ID:ukd1,项目名称:aria2rpc,代码行数:12,代码来源:aria2rpc.go

示例8: GetActive

func GetActive(keys []string) ([]map[string]interface{}, error) {
	method := "aria2.tellActive"
	paramArr := make([]interface{}, 0)
	if keys != nil && len(keys) > 0 {
		paramArr = append(paramArr, keys)
	}
	var reply = make([]map[string]interface{}, 10)
	err := httprpc.CallJson(RpcVersion, RpcUrl, method, paramArr, &reply)
	if err != nil {
		return nil, err
	}
	return reply, nil
}
开发者ID:ukd1,项目名称:aria2rpc,代码行数:13,代码来源:aria2rpc.go

示例9: ChangeOption

func ChangeOption(gid string, params map[string]string) (string, error) {
	method := "aria2.changeOption"
	paramArr := make([]interface{}, 2)
	paramArr[0] = "token:" + RpcSecret
	paramArr[1] = gid
	paramArr = append(paramArr, params)

	var reply string
	err := httprpc.CallJson(RpcVersion, RpcUrl, method, paramArr, &reply)
	if err != nil {
		return "", err
	}
	return reply, nil
}
开发者ID:headzoo,项目名称:aria2rpc,代码行数:14,代码来源:aria2rpc.go

示例10: GetStatus

func GetStatus(gid string, keys []string) (map[string]interface{}, error) {
	method := "aria2.tellStatus"
	paramArr := make([]interface{}, 1)
	paramArr[0] = gid
	if keys != nil && len(keys) > 0 {
		paramArr = append(paramArr, keys)
	}
	var reply = make(map[string]interface{})
	err := httprpc.CallJson(RpcVersion, RpcUrl, method, paramArr, &reply)
	if err != nil {
		return nil, err
	}
	return reply, nil
}
开发者ID:ukd1,项目名称:aria2rpc,代码行数:14,代码来源:aria2rpc.go

示例11: GetStopped

func GetStopped(offset, num int, keys []string) ([]map[string]interface{}, error) {
	method := "aria2.tellStopped"
	paramArr := make([]interface{}, 2)
	paramArr[0] = offset
	paramArr[1] = num
	if keys != nil && len(keys) > 0 {
		paramArr = append(paramArr, keys)
	}
	var reply = make([]map[string]interface{}, 10)
	err := httprpc.CallJson(RpcVersion, RpcUrl, method, paramArr, &reply)
	if err != nil {
		return nil, err
	}
	return reply, nil
}
开发者ID:ukd1,项目名称:aria2rpc,代码行数:15,代码来源:aria2rpc.go

示例12: Pause

func Pause(gid string, force bool) (string, error) {
	var method string
	if force {
		method = "aria2.forcePause"
	} else {
		method = "aria2.pause"
	}
	paramArr := make([]interface{}, 1)
	paramArr[0] = gid
	var replyGID string
	err := httprpc.CallJson(RpcVersion, RpcUrl, method, paramArr, &replyGID)
	if err != nil {
		return "", err
	}
	return replyGID, nil
}
开发者ID:ukd1,项目名称:aria2rpc,代码行数:16,代码来源:aria2rpc.go

示例13: Remove

func Remove(gid string, force bool) (string, error) {
	var method string
	if force {
		method = "aria2.forceRemove"
	} else {
		method = "aria2.remove"
	}
	paramArr := make([]interface{}, 2)
	paramArr[0] = "token:" + RpcSecret
	paramArr[1] = gid
	var replyGID string
	err := httprpc.CallJson(RpcVersion, RpcUrl, method, paramArr, &replyGID)
	if err != nil {
		return "", err
	}
	return replyGID, nil
}
开发者ID:headzoo,项目名称:aria2rpc,代码行数:17,代码来源:aria2rpc.go

示例14: AddUri

func AddUri(uri string, params map[string]interface{}) (string, error) {
	method := "aria2.addUri"
	paramArr := make([]interface{}, 1)
	uris := make([]string, 1)
	uris[0] = uri
	paramArr[0] = uris
	if params != nil {
		paramArr = append(paramArr, params)
	}

	var replyGID string
	err := httprpc.CallJson(RpcVersion, RpcUrl, method, paramArr, &replyGID)
	if err != nil {
		return "", err
	}
	return replyGID, nil
}
开发者ID:ukd1,项目名称:aria2rpc,代码行数:17,代码来源:aria2rpc.go

示例15: AddTorrent

func AddTorrent(path string) (string, error) {
	file, openFileErr := os.Open(path)
	if openFileErr != nil {
		return "", nil
	}

	fileBytes, readError := ioutil.ReadAll(bufio.NewReader(file))
	if readError != nil {
		return "", readError
	}
	coder := base64.StdEncoding
	encoded := coder.EncodeToString(fileBytes)

	method := "aria2.addTorrent"
	paramArr := make([]interface{}, 1)
	paramArr[0] = encoded
	var replyGID string
	err := httprpc.CallJson(RpcVersion, RpcUrl, method, paramArr, &replyGID)
	if err != nil {
		return "", err
	}
	return replyGID, nil
}
开发者ID:ukd1,项目名称:aria2rpc,代码行数:23,代码来源:aria2rpc.go


注:本文中的github.com/kdar/httprpc.CallJson函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。