~ubuntu-branches/ubuntu/utopic/hockeypuck/utopic-proposed

« back to all changes in this revision

Viewing changes to build/src/code.google.com/p/gorilla/rpc/json/doc.go

  • Committer: Package Import Robot
  • Author(s): Casey Marshall
  • Date: 2014-04-13 20:06:01 UTC
  • Revision ID: package-import@ubuntu.com-20140413200601-oxdlqn1gy0x8m55u
Tags: 1.0~rel20140413+7a1892a~trusty
Hockeypuck 1.0 release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2009 The Go Authors. All rights reserved.
 
2
// Copyright 2012 The Gorilla Authors. All rights reserved.
 
3
// Use of this source code is governed by a BSD-style
 
4
// license that can be found in the LICENSE file.
 
5
 
 
6
/*
 
7
Package gorilla/rpc/json provides a codec for JSON-RPC over HTTP services.
 
8
 
 
9
To register the codec in a RPC server:
 
10
 
 
11
        import (
 
12
                "http"
 
13
                "code.google.com/p/gorilla/rpc"
 
14
                "code.google.com/p/gorilla/rpc/json"
 
15
        )
 
16
 
 
17
        func init() {
 
18
                s := rpc.NewServer()
 
19
                s.RegisterCodec(json.NewCodec(), "application/json")
 
20
                // [...]
 
21
                http.Handle("/rpc", s)
 
22
        }
 
23
 
 
24
A codec is tied to a content type. In the example above, the server will use
 
25
the JSON codec for requests with "application/json" as the value for the
 
26
"Content-Type" header.
 
27
 
 
28
This package follows the JSON-RPC 1.0 specification:
 
29
 
 
30
        http://json-rpc.org/wiki/specification
 
31
 
 
32
Request format is:
 
33
 
 
34
        method:
 
35
                The name of the method to be invoked, as a string in dotted notation
 
36
                as in "Service.Method".
 
37
        params:
 
38
                An array with a single object to pass as argument to the method.
 
39
        id:
 
40
                The request id, a uint. It is used to match the response with the
 
41
                request that it is replying to.
 
42
 
 
43
Response format is:
 
44
 
 
45
        result:
 
46
                The Object that was returned by the invoked method,
 
47
                or null in case there was an error invoking the method.
 
48
        error:
 
49
                An Error object if there was an error invoking the method,
 
50
                or null if there was no error.
 
51
        id:
 
52
                The same id as the request it is responding to.
 
53
 
 
54
Check the gorilla/rpc documentation for more details:
 
55
 
 
56
        http://gorilla-web.appspot.com/pkg/gorilla/rpc
 
57
*/
 
58
package json