2 Star 0 Fork 0

mirrors_codegangsta / gin

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
config.go 633 Bytes
一键复制 编辑 原始数据 按行查看 历史
Jakob Gillich 提交于 2016-12-07 05:58 . add TLS support
package gin
import (
"encoding/json"
"fmt"
"os"
)
type Config struct {
Laddr string `json:"laddr"`
Port int `json:"port"`
ProxyTo string `json:"proxy_to"`
KeyFile string `json:"key_file"`
CertFile string `json:"cert_file"`
}
func LoadConfig(path string) (*Config, error) {
configFile, err := os.Open(path)
if err != nil {
return nil, fmt.Errorf("Unable to read configuration file %s", path)
}
config := new(Config)
decoder := json.NewDecoder(configFile)
err = decoder.Decode(&config)
if err != nil {
return nil, fmt.Errorf("Unable to parse configuration file %s", path)
}
return config, nil
}
1
https://gitee.com/mirrors_codegangsta/gin.git
git@gitee.com:mirrors_codegangsta/gin.git
mirrors_codegangsta
gin
gin
2c98d96c9244

搜索帮助