Documentation ¶
Overview ¶
Package webrpc implements a web-based JSON, Gob and ProtoBuf RPC protocol roughly compatible with google-protorpc. It works in tandem with the go-rpcgen protoc-gen-go plugin, which generates the bindings.
By default, webrpc.DefaultServeMux is handled by the default HTTP package, so it will interoperate with standard HTTP servers and AppEngine.
Index ¶
Constants ¶
const (
// DefaultRPCPath is the prefix of all RPC handlers registered by webrpc
DefaultRPCPath = "/_webRPC_"
)
Variables ¶
var DefaultServeMux = ServeMux{}
DefaultServeMux is the default ServeMux used when nil is passed to the Register...Web functions and ListenAndServe.
Functions ¶
func ListenAndServe ¶
ListenAndServe is a utility function for starting up the HTTP server without needing to import the net/http package.
func Post ¶
Post is used by the code generated automatically by protoc-gen-go for making RPC calls remotely.
func RegisterProtocol ¶
func RegisterProtocol(p Protocol)
Types ¶
type Call ¶
type Call struct { http.ResponseWriter *http.Request ContentType string }
A Call is an incoming request. These are used in the code generated automatically by protoc-gen-go.
func (*Call) ReadRequest ¶
ReadRequest is used by the code generated automatically by protoc-gen-go.
func (*Call) WriteResponse ¶
WriteResponse is used by the code generated automatically by protoc-gen-go.
type Handler ¶
A Handler processes an incoming RPC request. These are generated automatically by protoc-gen-go for service definitions and don't usually need to be registered manually.
type Protocol ¶
type Protocol interface { String() string // Return the MIME type of the protocol Decode(io.Reader, interface{}) error Encode(io.Writer, interface{}) error }
A Protocol is a predefined encoder/decoder for WebRPC.
var Gob Protocol = gobProtocol{}
Gob implements the Go Object implementation of the webrpc.Protocol interface.
var JSON Protocol = jsonProtocol{}
JSON implements the Javascript Object Notation implementation of the webrpc.Protocol interface.
var ProtoBuf Protocol = pbProtocol{}
ProtoBuf implements the Google Protocol Buffer implementation of the webrpc.Protocol interface. This is currently not allowed on AppEngine.