2016-08-13 09:44:36 -04:00
|
|
|
package ws
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (this *Config) UnmarshalJSON(data []byte) error {
|
|
|
|
type JsonConfig struct {
|
|
|
|
ConnectionReuse bool `json:"connectionReuse"`
|
|
|
|
Path string `json:"Path"`
|
|
|
|
Pto string `json:"Pto"`
|
2016-08-13 09:56:51 -04:00
|
|
|
Cert string `json:"Cert"`
|
2016-08-13 10:07:47 -04:00
|
|
|
PrivKey string `json:"PrivKey"`
|
2016-08-13 09:44:36 -04:00
|
|
|
}
|
|
|
|
jsonConfig := &JsonConfig{
|
|
|
|
ConnectionReuse: true,
|
|
|
|
Path: "",
|
|
|
|
Pto: "",
|
|
|
|
}
|
|
|
|
if err := json.Unmarshal(data, jsonConfig); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
this.ConnectionReuse = jsonConfig.ConnectionReuse
|
|
|
|
this.Path = jsonConfig.Path
|
|
|
|
this.Pto = jsonConfig.Pto
|
2016-08-13 09:56:51 -04:00
|
|
|
this.PrivKey = jsonConfig.PrivKey
|
|
|
|
this.Cert = jsonConfig.Cert
|
2016-08-13 09:44:36 -04:00
|
|
|
return nil
|
|
|
|
}
|