OSDN Git Service

new repo
[bytom/vapor.git] / net / http / httpjson / doc.go
1 /*
2
3 Package httpjson creates HTTP handlers to map request
4 and response formats onto Go function signatures.
5 The request body is decoded as a JSON text
6 into an arbitrary value and the function's return value
7 is encoded as a JSON text for the response body.
8 The function's signature determines the types of the
9 input and output values.
10
11 For example, the handler for a function with signature
12
13   func(struct{ FavColor, Birthday string })
14
15 would read the JSON request body into a variable
16 of type struct{ FavColor, Birthday string }, then call
17 the function.
18
19 The allowed elements of a function signature are:
20
21   parameters:
22   Context (optional)
23   request body (optional)
24
25   return values:
26   response body (optional)
27   error (optional)
28
29 All elements are optional.
30 Thus, the smallest possible function signature is
31
32   func()
33
34 If the function returns a non-nil error,
35 the handler will call the error function provided
36 in its constructor.
37 Otherwise, the handler will write the return value
38 as JSON text to the response body.
39 If the return type is omitted, the handler will send
40 a default response value.
41
42 */
43 package httpjson