예제 #1
0
func TestHttpService(t *testing.T) {
	service := hprose.NewHttpService()
	service.AddFunction("hello", hello)
	service.AddMethods(new(testServe))
	server := httptest.NewServer(service)
	defer server.Close()
	client := hprose.NewClient(server.URL)
	var ro *testRemoteObject2
	client.UseService(&ro)
	if s, err := ro.Hello("World"); err != nil {
		t.Error(err.Error())
	} else {
		fmt.Println(s)
	}
	if a, b, err := ro.Swap(1, 2); err != nil {
		t.Error(err.Error())
	} else {
		fmt.Println(a, b)
	}
	if sum, err := ro.Sum(1); err != nil {
		fmt.Println(err.Error())
	} else {
		t.Error(sum)
	}
	if sum, err := ro.Sum(1, 2, 3, 4, 5); err != nil {
		t.Error(err.Error())
	} else {
		fmt.Println(sum)
	}
	if err := ro.PanicTest(); err != nil {
		fmt.Println(err.Error())
	} else {
		t.Error("missing panic")
	}
}
예제 #2
0
func main() {
	hprose.ClassManager.Register(reflect.TypeOf(A{}), "A", "json")
	service := hprose.NewHttpService()
	service.ServiceEvent = &ServerEvent{}
	service.DebugEnabled = true
	service.AddFunction("hello", hello)
	service.AddFunction("getEmptySlice", getEmptySlice)
	http.ListenAndServe(":8080", service)
}
예제 #3
0
func main() {
	service := hprose.NewHttpService()
	service.DebugEnabled = true
	service.AddFunction("reboot", Reboot)
	service.AddFunction("shutdown", Shutdown)
	service.AddFunction("ipset", IpSet)
	service.AddFunction("dhcpset", DhcpSet)
	http.ListenAndServe(":8080", service)
}
예제 #4
0
파일: main.go 프로젝트: qgweb/new
func main() {
	var (
		host = config.GetConf().String("default::host")
		port = config.GetConf().String("default::port")
	)
	service := hprose.NewHttpService()
	service.AddFunction("domain-visitor", cpro.CproData{}.DomainVisitor)
	//service.AddFunction("record-cookie", cpro.CproData{}.ReocrdCookie)
	service.AddFunction("record-cookie", cpro.CproData{}.ReocrdCookieEx)
	service.AddFunction("domain-effect", cpro.CproData{}.DomainEffect)
	service.AddFunction("reocrd-advert", cpro.CproData{}.RecordAdvertPutInfo)
	http.ListenAndServe(host+":"+port, service)
}
예제 #5
0
func main() {
	service := hprose.NewHttpService()
	service.AddFunction("WcMessageInfo", WcMessageInfo)
	service.AddFunction("WcOwnInfo", WcOwnInfo)
	service.AddFunction("WcSendMsg_Text", WcSendMsg_Text)
	service.AddFunction("WcGroupSendMsg_Text", WcGroupSendMsg_Text)
	service.AddFunction("WcBand", WcBand)
	service.AddFunction("GetQrcode", GetQrcode)
	service.AddFunction("GetAvatar", GetAvatar)
	service.AddFunction("GetFollowUserGroup", GetFollowUserGroup)
	var port string = "1245"
	fmt.Println("开始监听" + port + "端口")
	http.ListenAndServe(":"+port, service)
}
예제 #6
0
func main() {
	hprose.ClassManager.Register(reflect.TypeOf(User{}), "User", "json")
	service := hprose.NewHttpService()
	service.AddFunction("getUser", getUser)
	http.ListenAndServe(":8080", service)
}
예제 #7
0
func main() {
	service := hprose.NewHttpService()
	service.AddFunction("hello", hello)
	http.ListenAndServe(":8080", service)
}