forked from premendrasingh/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
39 lines (31 loc) · 769 Bytes
/
config.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
package server
import (
"errors"
"github.com/elastic/beats/libbeat/common"
)
type HttpServerConfig struct {
Paths []PathConfig `config:"paths"`
DefaultPath PathConfig `config:"default_path"`
}
type PathConfig struct {
Path string `config:"path"`
Fields common.MapStr `config:"fields"`
Namespace string `config:"namespace"`
}
func defaultHttpServerConfig() HttpServerConfig {
return HttpServerConfig{
DefaultPath: PathConfig{
Path: "/",
Namespace: "http",
},
}
}
func (p PathConfig) Validate() error {
if p.Namespace == "" {
return errors.New("`namespace` can not be empty in path configuration")
}
if p.Path == "" {
return errors.New("`path` can not be empty in path configuration")
}
return nil
}