json config parser

This commit is contained in:
Darien Raymond
2016-10-17 14:35:13 +02:00
parent e866ff24a4
commit 5a311cbe08
85 changed files with 9357 additions and 9052 deletions
-22
View File
@@ -1,22 +0,0 @@
// +build json
package http
import (
"encoding/json"
"errors"
)
// UnmarshalJSON implements json.Unmarshaler
func (this *ServerConfig) UnmarshalJSON(data []byte) error {
type JsonConfig struct {
Timeout uint32 `json:"timeout"`
}
jsonConfig := new(JsonConfig)
if err := json.Unmarshal(data, jsonConfig); err != nil {
return errors.New("HTTP: Failed to parse config: " + err.Error())
}
this.Timeout = jsonConfig.Timeout
return nil
}
-3
View File
@@ -1,3 +0,0 @@
// +build json
package http_test