mirror of
https://github.com/v2fly/v2ray-core
synced 2024-02-27 03:18:06 +00:00
json config parser
This commit is contained in:
@@ -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
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
// +build json
|
||||
|
||||
package http_test
|
||||
Reference in New Issue
Block a user