1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-10 18:00:43 +00:00
v2fly/proxy/http/config_json.go
2016-10-16 14:22:21 +02:00

23 lines
448 B
Go

// +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
}