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