Documentation ¶
Overview ¶
Package drpcmux is a handler to dispatch rpcs to implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
Mux is an implementation of Handler to serve drpc connections to the appropriate Receivers registered by Descriptions.
func (*Mux) Register ¶
func (m *Mux) Register(srv interface{}, desc drpc.Description) error
Register associates the rpcs described by the description in the server. It returns an error if there was a problem registering it.
func (*Mux) ServeHTTP ¶ added in v0.0.15
func (m *Mux) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP handles unitary rpcs over an http request. The rpcs are hosted at a path based on their name, like `/service.Server/Method` and accept the request protobuf in json. The response will either be of the form
{ "status": "ok", "response": ... }
if the request was successful, or
{ "status": "error", "error": ..., "code": ... }
where error is a textual description of the error, and code is the numeric code that was set with drpcerr, if any.
Metadata can be attached by adding the "X-Drpc-Metadata" header to the request possibly multiple times. The format is
X-Drpc-Metadata: percentEncode(key)=percentEncode(value)
where percentEncode is the encoding used for query strings. Only the '%' and '=' characters are necessary to be escaped.