Example #1
0
func main() {

	server := rpcplus.NewServer()

	server.Register(new(twitterapi.Account))

	server.Register(new(twitterapi.Profile))

	server.Register(new(twitterapi.Tweet))

	rpcwrap.ServeCustomRPC(
		Mux,
		server,
		false,  // use auth
		"json", // codec name
		jsonrpc.NewServerCodec,
	)

	rpcwrap.ServeHTTPRPC(
		Mux,                    // httpmuxer
		server,                 // rpcserver
		"http_json",            // codec name
		jsonrpc.NewServerCodec, // jsoncodec
		ContextCreator,         // contextCreator
	)

	fmt.Println("Server listening on 3000")
	http.ListenAndServe("localhost:3000", Mux)
}
Example #2
0
// ServeCustomRPC serves bsonrpc codec with a custom rpc server
func ServeCustomRPC(handler *http.ServeMux, server *rpc.Server, useAuth bool) {
	rpcwrap.ServeCustomRPC(handler, server, useAuth, codecName, NewServerCodec)
}