mapserver/app/config.go
NatureFreshMilk 2eb0d3851a dump config
2019-01-18 09:11:13 +01:00

35 lines
576 B
Go

package app
import (
"encoding/json"
"io/ioutil"
"os"
)
type Config struct {
Port int `json:"port"`
EnableInitialRendering bool `json:"enableinitialrendering"`
}
func ParseConfig(filename string) (*Config, error) {
cfg := Config{
Port: 80,
EnableInitialRendering: true,
}
info, err := os.Stat(filename)
if info != nil && err == nil {
data, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
err = json.Unmarshal(data, &cfg)
if err != nil {
return nil, err
}
}
return &cfg, nil
}