config_json.go 520 B

1234567891011121314151617181920212223242526
  1. // +build json
  2. package http
  3. import (
  4. "encoding/json"
  5. "errors"
  6. "github.com/v2ray/v2ray-core/proxy/internal"
  7. )
  8. // UnmarshalJSON implements json.Unmarshaler
  9. func (this *Config) UnmarshalJSON(data []byte) error {
  10. type JsonConfig struct {
  11. }
  12. jsonConfig := new(JsonConfig)
  13. if err := json.Unmarshal(data, jsonConfig); err != nil {
  14. return errors.New("HTTP: Failed to parse config: " + err.Error())
  15. }
  16. return nil
  17. }
  18. func init() {
  19. internal.RegisterInboundConfig("http", func() interface{} { return new(Config) })
  20. }