コード例 #1
0
func WeariverseGistHandle(cm *wearscript.ConnectionManager, userId string, request []interface{}) {
	action := request[1].(string)
	channelResult := request[2].(string)
	fmt.Println("gist action: " + action + " result: " + channelResult)
	var dataJS interface{}
	var err error
	if action == "list" {
		dataJS, err = WeariverseGetGists(userId)
	} else {
		dataJS = "error:action"
	}
	if err != nil {
		fmt.Println(err)
	}
	cm.Publish(channelResult, dataJS)
}
コード例 #2
0
ファイル: github.go プロジェクト: rdegraci/wearscript-server
func GithubGistHandle(cm *wearscript.ConnectionManager, userId string, request []interface{}) {
	action := request[1].(string)
	channelResult := request[2].(string)
	fmt.Println("gist action: " + action + " result: " + channelResult)
	var dataJS interface{}
	var err error
	if action == "list" {
		dataJS, err = GithubGetGists(userId)
	} else if action == "get" {
		dataJS, err = GithubGetGist(userId, request[3].(string))
	} else if action == "create" {
		dataJS, err = GithubCreateGist(userId, request[3].(bool), request[4], githubConvertFiles(request[5].(map[interface{}]interface{})))
	} else if action == "modify" {
		dataJS, err = GithubModifyGist(userId, request[3].(string), request[4], githubConvertFiles(request[5].(map[interface{}]interface{})))
	} else if action == "fork" {
		dataJS, err = GithubForkGist(userId, request[3].(string))
	} else {
		dataJS = "error:action"
	}
	if err != nil {
		fmt.Println(err)
	}
	cm.Publish(channelResult, dataJS)
}