-
Notifications
You must be signed in to change notification settings - Fork 14
/
server.go
51 lines (42 loc) · 2.17 KB
/
server.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/avenga/couper/config/meta"
)
var _ Inline = &Server{}
// Server represents the <Server> object.
type Server struct {
AccessControl []string `hcl:"access_control,optional" docs:"The [access controls](../access-control) to protect the server. Inherited by nested blocks."`
APIs APIs `hcl:"api,block" docs:"Configures an API (zero or more)."`
BasePath string `hcl:"base_path,optional" docs:"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" docs:"Disables access controls by name."`
Endpoints Endpoints `hcl:"endpoint,block" docs:"Configures a free [endpoint](/configuration/block/endpoint) (zero or more)."`
ErrorFile string `hcl:"error_file,optional" docs:"Location of the error file template."`
Files FilesBlocks `hcl:"files,block" docs:"Configures file serving (zero or more)."`
Hosts []string `hcl:"hosts,optional" docs:"Mandatory, if there is more than one {server} block."`
Name string `hcl:"name,label,optional"`
Remain hcl.Body `hcl:",remain"`
SPAs SPAs `hcl:"spa,block" docs:"Configures an SPA (zero or more)."`
TLS *ServerTLS `hcl:"tls,block" docs:"Configures [server TLS](/configuration/block/server_tls) (zero or one)."`
}
// Servers represents a list of <Server> objects.
type Servers []*Server
// Inline implements the <Inline> interface.
func (s Server) Inline() interface{} {
type Inline struct {
meta.ResponseHeadersAttributes
meta.LogFieldsAttribute
}
return &Inline{}
}
// Schema implements the <Inline> interface.
func (s Server) 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)
}