-
Notifications
You must be signed in to change notification settings - Fork 14
/
spa.go
50 lines (40 loc) · 1.57 KB
/
spa.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
package config
import (
"github.com/hashicorp/hcl/v2"
"github.com/hashicorp/hcl/v2/gohcl"
"github.com/avenga/couper/config/meta"
)
var _ Inline = &Spa{}
type SPAs []*Spa
// Spa represents the <Spa> object.
type Spa struct {
AccessControl []string `hcl:"access_control,optional" docs:"Sets predefined [access control](../access-control) for {spa} block context."`
BasePath string `hcl:"base_path,optional" docs:"Configures the path prefix for all requests."`
BootstrapFile string `hcl:"bootstrap_file" docs:"Location of the bootstrap file."`
CORS *CORS `hcl:"cors,block" docs:"Configure [CORS](cors) settings."`
DisableAccessControl []string `hcl:"disable_access_control,optional" docs:"Disables access controls by name."`
Name string `hcl:"name,label,optional"`
Paths []string `hcl:"paths" docs:"List of SPA paths that need the bootstrap file."`
Remain hcl.Body `hcl:",remain"`
}
// HCLBody implements the <Inline> interface.
func (s Spa) HCLBody() hcl.Body {
return s.Remain
}
// Inline implements the <Inline> interface.
func (s Spa) Inline() interface{} {
type Inline struct {
meta.ResponseHeadersAttributes
meta.LogFieldsAttribute
}
return &Inline{}
}
// Schema implements the <Inline> interface.
func (s Spa) Schema(inline bool) *hcl.BodySchema {
if !inline {
schema, _ := gohcl.ImpliedBodySchema(s)
return schema
}
schema, _ := gohcl.ImpliedBodySchema(s.Inline())
return meta.MergeSchemas(schema, meta.ResponseHeadersAttributesSchema, meta.LogFieldsAttributeSchema)
}