arnaucube
arnaucube/goImgServerPublic Self-hosted repository
goImgServer/readConfig.go
readConfig.goRaw
 1package main
 2
 3import (
 4	"encoding/json"
 5	"fmt"
 6	"io/ioutil"
 7)
 8
 9type Config struct {
10	Folder     string   `json:"foldIPs`
11	BlockedIPs []string `json:"blockedIPs"`
12	AllowedIPs []string `json:"allowedIPs"`
13	ImgWidth   int      `json:"imgWidth"`
14	ImgHeigh   int      `json:"imgHeigh"`
15}
16
17var config Config
18
19func readConfig(path string) {
20	file, err := ioutil.ReadFile(path)
21	if err != nil {
22		fmt.Println("error: ", err)
23	}
24	content := string(file)
25	json.Unmarshal([]byte(content), &config)
26}