File tree Expand file tree Collapse file tree 1 file changed +0
-37
lines changed Expand file tree Collapse file tree 1 file changed +0
-37
lines changed Original file line number Diff line number Diff line change 1
1
package paperswithcode_go
2
2
3
3
import (
4
- "encoding/json"
5
- "errors"
6
- "fmt"
7
4
"github.com/codingpot/paperswithcode-go/internal/transport"
8
5
"net/http"
9
6
"time"
@@ -45,37 +42,3 @@ type Client struct {
45
42
HTTPClient * http.Client
46
43
apiToken string
47
44
}
48
-
49
- type errorResponse struct {
50
- Code int `json:"code"`
51
- Message string `json:"message"`
52
- }
53
-
54
- func (c * Client ) sendRequest (req * http.Request , v interface {}) error {
55
- req .Header .Set ("Content-Type" , "application/json; charset=utf-8" )
56
- req .Header .Set ("Accept" , "application/json; charset=utf-8" )
57
-
58
- res , err := c .HTTPClient .Do (req )
59
- if err != nil {
60
- return err
61
- }
62
-
63
- defer res .Body .Close ()
64
-
65
- if res .StatusCode < http .StatusOK || res .StatusCode >= http .StatusBadRequest {
66
- var errRes errorResponse
67
- if err = json .NewDecoder (res .Body ).Decode (& errRes ); err == nil {
68
- return errors .New (errRes .Message )
69
- }
70
-
71
- return fmt .Errorf ("unknown error, status code: %d" , res .StatusCode )
72
- }
73
-
74
- if err = json .NewDecoder (res .Body ).Decode (& v ); err != nil {
75
- return err
76
- }
77
-
78
- // fmt.Println(fullResponse)
79
-
80
- return nil
81
- }
You can’t perform that action at this time.
0 commit comments