arnaucube
arnaucube/konstruiPublic Self-hosted repository
konstrui/readKonstruiConfig.go
readKonstruiConfig.goRaw
 1package main
 2
 3import (
 4	"encoding/json"
 5	"fmt"
 6	"io/ioutil"
 7)
 8
 9//RepeatPages is from the json config, is an array inside KonstruiConfig
10type RepeatPages struct {
11	HtmlPage string `json:"htmlPage"`
12	Data     string `json:"data"`
13}
14
15//KonstruiConfig is the configuration from the file konstruiConfig.json, on the folder /webInput
16type KonstruiConfig struct {
17	Title       string   `json:"title"`
18	Author      string   `json:"author"`
19	Github      string   `json:"github"`
20	Website     string   `json:"website"`
21	Files       []string `json:"files"`
22	RepeatPages []RepeatPages
23}
24
25var konstruiConfig KonstruiConfig
26
27func readKonstruiConfig(path string) {
28	file, e := ioutil.ReadFile(path)
29	if e != nil {
30		fmt.Println("error:", e)
31	}
32	content := string(file)
33	json.Unmarshal([]byte(content), &konstruiConfig)
34}