From cfe3b6466c396bc47e6f5c276dc1aecab5f1b1a4 Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 8 Jan 2024 17:47:52 +0800 Subject: [PATCH] update bitget v2 get_symbols_request_requestgen --- .../v2/get_symbols_request_requestgen.go | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/pkg/exchange/bitget/bitgetapi/v2/get_symbols_request_requestgen.go b/pkg/exchange/bitget/bitgetapi/v2/get_symbols_request_requestgen.go index 700583094..b91ad44c9 100644 --- a/pkg/exchange/bitget/bitgetapi/v2/get_symbols_request_requestgen.go +++ b/pkg/exchange/bitget/bitgetapi/v2/get_symbols_request_requestgen.go @@ -137,15 +137,29 @@ func (g *GetSymbolsRequest) Do(ctx context.Context) ([]Symbol, error) { } var apiResponse bitgetapi.APIResponse - if err := response.DecodeJSON(&apiResponse); err != nil { - return nil, err + + type responseUnmarshaler interface { + Unmarshal(data []byte) error + } + + if unmarshaler, ok := interface{}(&apiResponse).(responseUnmarshaler); ok { + if err := unmarshaler.Unmarshal(response.Body); err != nil { + return nil, err + } + } else { + // The line below checks the content type, however, some API server might not send the correct content type header, + // Hence, this is commented for backward compatibility + // response.IsJSON() + if err := response.DecodeJSON(&apiResponse); err != nil { + return nil, err + } } type responseValidator interface { Validate() error } - validator, ok := interface{}(apiResponse).(responseValidator) - if ok { + + if validator, ok := interface{}(&apiResponse).(responseValidator); ok { if err := validator.Validate(); err != nil { return nil, err }