예제 #1
0
파일: wsapi.go 프로젝트: Davidx7/FactomCode
func handleProperties(ctx *web.Context) {

	r := new(common.Properties)
	r.Factomd_Version = common.FACTOMD_VERSION
	r.Protocol_Version = btcd.ProtocolVersion

	if p, err := json.Marshal(r); err != nil {
		wsLog.Error(err)
		ctx.WriteHeader(httpBad)
		ctx.Write([]byte(err.Error()))
		return
	} else {
		ctx.Write(p)
	}
}
예제 #2
0
func GetProperties() (*common.Properties, error) {
	str := fmt.Sprintf("http://%s/v1/properties/", ipaddressFD+portNumberFD)
	resp, err := http.Get(str)
	if err != nil {
		return nil, err
	}
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		resp.Body.Close()
		return nil, err
	}
	resp.Body.Close()

	b := new(common.Properties)
	if err := json.Unmarshal(body, b); err != nil {
		return nil, err
	}
	b.Fctwallet_Version = Version
	return b, nil
}