-
Notifications
You must be signed in to change notification settings - Fork 14
/
files.go
51 lines (41 loc) · 1.64 KB
/
files.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
package config
import (
"github.com/hashicorp/hcl/v2"
"github.com/hashicorp/hcl/v2/gohcl"
"github.com/hashicorp/hcl/v2/hclsyntax"
"github.com/avenga/couper/config/meta"
)
var _ Inline = &Files{}
type FilesBlocks []*Files
// Files represents the <Files> object.
type Files struct {
AccessControl []string `hcl:"access_control,optional" docs:"Sets predefined access control for this block context."`
BasePath string `hcl:"base_path,optional" docs:"Configures the path prefix for all requests."`
CORS *CORS `hcl:"cors,block" docs:"Configures [CORS](/configuration/block/cors) settings (zero or one)."`
DisableAccessControl []string `hcl:"disable_access_control,optional"`
DocumentRoot string `hcl:"document_root" docs:"Location of the document root (directory)."`
ErrorFile string `hcl:"error_file,optional" docs:"Location of the error file template."`
Name string `hcl:"name,label,optional"`
Remain hcl.Body `hcl:",remain"`
}
// HCLBody implements the <Body> interface.
func (f Files) HCLBody() *hclsyntax.Body {
return f.Remain.(*hclsyntax.Body)
}
// Inline implements the <Inline> interface.
func (f Files) Inline() interface{} {
type Inline struct {
meta.ResponseHeadersAttributes
meta.LogFieldsAttribute
}
return &Inline{}
}
// Schema implements the <Inline> interface.
func (f Files) Schema(inline bool) *hcl.BodySchema {
if !inline {
schema, _ := gohcl.ImpliedBodySchema(f)
return schema
}
schema, _ := gohcl.ImpliedBodySchema(f.Inline())
return meta.MergeSchemas(schema, meta.ResponseHeadersAttributesSchema, meta.LogFieldsAttributeSchema)
}