Coder Social home page Coder Social logo

go-rpc's Introduction

go-rpc

An RPC framework using http requests.

GoDoc

Different from the net/rpc package. The methods of the serving object can be of much flexible. The only requirement is the parameters and return values are be represented by JSON.

The first parameter could be *http.Request, which will be set to the instance in the handler, and not counts to the NumIn in client.Call. This is especially usefully in Google App Engine.

Example

//// The server model
type Arith int
		
func (*Arith) Add(a, b int) int {
	return a + b
}

func (*Arith) Sub(r *http.Request, a, b int) int {
	return a - b
}
		
//// Server
Register(new(Arith))
	
http.ListenAndServe(":1235", nil)
    
		
//// Client
client := NewClient(http.DefaultClient, "http://localhost:1235")
	
A, B := 1, 2
var C int
err := client.Call(2, "Add", A, B, &C)
err = client.Call(2, "Sub", A, B, &C)

You needn't define a type of input arguments for each method, as in using net/rpc.

LICENSE

BSD license.

go-rpc's People

Contributors

daviddengcn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.