-
Notifications
You must be signed in to change notification settings - Fork 4
/
caddy.go
66 lines (53 loc) · 1.96 KB
/
caddy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package jsonschema
// moduleMap is map of namespaces to namespace modules.
// It is used by module loaders to identify modules in namespace.
var moduleMap = map[string]Modules{}
// flatModule is a flat map of module namespace to module
// without nesting.
// It is used during schema generation.
var flatModuleMap = Modules{}
// Module is a basic information about a Caddy module.
type Module struct {
Name string
Type interface{}
Interface Interface
}
// Modules is list of Module. Map is used for quicker access
// and ease of fetching module name.
type Modules map[string]Module
// rootDocAPIResp holds the value for the API response of the root
// config.
var rootDocAPIResp DocAPIResp
// flatCaddyDocMap is a flat map of module path to API response
// without nesting.
// It is used during schema generation to retrieve module docs.
var flatCaddyDocMap = map[string]*DocAPIResp{}
// DocStruct is the API response structure for a type.
type DocStruct struct {
Type string `json:"type,omitempty"`
Package string `json:"type_name,omitempty"`
Doc string `json:"doc,omitempty"`
Key string `json:"key,omitempty"`
Value *DocStruct `json:"value,omitempty"`
Elems *DocStruct `json:"elems,omitempty"`
MapKeys struct {
Type string `json:"type,omitempty"`
} `json:"map_keys,omitempty"`
Namespace string `json:"module_namespace,omitempty"`
InlineKey string `json:"module_inline_key,omitempty"`
StructFields []*DocStruct `json:"struct_fields,omitempty"`
}
// DocAPIResp is the API response for a namespace documentation request.
type DocAPIResp struct {
StatusCode int `json:"status_code"`
Result struct {
Structure *DocStruct `json:"structure,omitempty"`
Namespaces DocNamespace `json:"namespaces,omitempty"`
} `json:"result"`
}
// DocNamespace is the API response structure for namespaces
type DocNamespace map[string][]struct {
Name string `json:"name,omitempty"`
Docs string `json:"docs,omitempty"`
Structure *DocStruct `json:"-"`
}