@@ -16,45 +16,6 @@ const (
1616 CookieMaxAge = 60 * 60 * 24
1717)
1818
19- // NewConfig read YAML config file, required to start Gomagpie
20- func NewConfig (configFile string ) (* Config , error ) {
21- yamlData , err := os .ReadFile (configFile )
22- if err != nil {
23- return nil , fmt .Errorf ("failed to read config file %w" , err )
24- }
25-
26- // expand environment variables
27- yamlData = []byte (os .ExpandEnv (string (yamlData )))
28-
29- var config * Config
30- err = yaml .Unmarshal (yamlData , & config )
31- if err != nil {
32- return nil , fmt .Errorf ("failed to unmarshal config file, error: %w" , err )
33- }
34- err = validateLocalPaths (config )
35- if err != nil {
36- return nil , fmt .Errorf ("validation error in config file, error: %w" , err )
37- }
38- return config , nil
39- }
40-
41- // UnmarshalYAML hooks into unmarshalling to set defaults and validate config
42- func (c * Config ) UnmarshalYAML (unmarshal func (interface {}) error ) error {
43- type cfg Config
44- if err := unmarshal ((* cfg )(c )); err != nil {
45- return err
46- }
47-
48- // init config
49- if err := setDefaults (c ); err != nil {
50- return err
51- }
52- if err := validate (c ); err != nil {
53- return err
54- }
55- return nil
56- }
57-
5819type Config struct {
5920 // Version of the API. When releasing a new version which contains backwards-incompatible changes, a new major version must be released.
6021 Version string `yaml:"version" json:"version" validate:"required,semver" default:"1.0.0"`
@@ -102,6 +63,45 @@ type Config struct {
10263 Collections GeoSpatialCollections `yaml:"collections,omitempty" json:"collections,omitempty" validate:"required,dive"`
10364}
10465
66+ // NewConfig read YAML config file, required to start Gomagpie
67+ func NewConfig (configFile string ) (* Config , error ) {
68+ yamlData , err := os .ReadFile (configFile )
69+ if err != nil {
70+ return nil , fmt .Errorf ("failed to read config file %w" , err )
71+ }
72+
73+ // expand environment variables
74+ yamlData = []byte (os .ExpandEnv (string (yamlData )))
75+
76+ var config * Config
77+ err = yaml .Unmarshal (yamlData , & config )
78+ if err != nil {
79+ return nil , fmt .Errorf ("failed to unmarshal config file, error: %w" , err )
80+ }
81+ err = validateLocalPaths (config )
82+ if err != nil {
83+ return nil , fmt .Errorf ("validation error in config file, error: %w" , err )
84+ }
85+ return config , nil
86+ }
87+
88+ // UnmarshalYAML hooks into unmarshalling to set defaults and validate config
89+ func (c * Config ) UnmarshalYAML (unmarshal func (any ) error ) error {
90+ type cfg Config
91+ if err := unmarshal ((* cfg )(c )); err != nil {
92+ return err
93+ }
94+
95+ // init config
96+ if err := setDefaults (c ); err != nil {
97+ return err
98+ }
99+ if err := validate (c ); err != nil {
100+ return err
101+ }
102+ return nil
103+ }
104+
105105type License struct {
106106 // Name of the license, e.g. MIT, CC0, etc
107107 Name string `yaml:"name" json:"name" validate:"required" default:"CC0"`
0 commit comments