...
1 package restful
2
3
4
5
6
7 type RouteReader interface {
8 Method() string
9 Consumes() []string
10 Path() string
11 Doc() string
12 Notes() string
13 Operation() string
14 ParameterDocs() []*Parameter
15
16 Metadata() map[string]interface{}
17 Deprecated() bool
18 }
19
20 type routeAccessor struct {
21 route *Route
22 }
23
24 func (r routeAccessor) Method() string {
25 return r.route.Method
26 }
27 func (r routeAccessor) Consumes() []string {
28 return r.route.Consumes[:]
29 }
30 func (r routeAccessor) Path() string {
31 return r.route.Path
32 }
33 func (r routeAccessor) Doc() string {
34 return r.route.Doc
35 }
36 func (r routeAccessor) Notes() string {
37 return r.route.Notes
38 }
39 func (r routeAccessor) Operation() string {
40 return r.route.Operation
41 }
42 func (r routeAccessor) ParameterDocs() []*Parameter {
43 return r.route.ParameterDocs[:]
44 }
45
46
47 func (r routeAccessor) Metadata() map[string]interface{} {
48 return copyMap(r.route.Metadata)
49 }
50 func (r routeAccessor) Deprecated() bool {
51 return r.route.Deprecated
52 }
53
54
55 func copyMap(m map[string]interface{}) map[string]interface{} {
56 cp := make(map[string]interface{})
57 for k, v := range m {
58 vm, ok := v.(map[string]interface{})
59 if ok {
60 cp[k] = copyMap(vm)
61 } else {
62 cp[k] = v
63 }
64 }
65 return cp
66 }
67
View as plain text