aboutsummaryrefslogtreecommitdiff
path: root/config/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'config/config.go')
-rw-r--r--config/config.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/config/config.go b/config/config.go
new file mode 100644
index 0000000..2c94dbe
--- /dev/null
+++ b/config/config.go
@@ -0,0 +1,31 @@
+package config
+
+import (
+ "os"
+
+ "gopkg.in/yaml.v2"
+)
+
+type Config struct {
+ // AppConfig is the application level configuration entries
+ App App `yaml:"App"`
+ // Menus is the list of menus. The first one is the default menu for an anonymous user, the second one is the default menu for an authenticated user
+ Menus []Menu `yaml:"Menus"`
+ // Games is the list of games.
+ Games map[string]Game `yaml:"Games"`
+}
+
+// LoadFile loads the config from a given file
+func LoadFile(path string) (config Config, err error) {
+ var f *os.File
+ f, err = os.Open(path)
+ if err != nil {
+ return
+ }
+ defer f.Close()
+ decoder := yaml.NewDecoder(f)
+ if err = decoder.Decode(&config); err != nil {
+ return
+ }
+ return
+}