@@ -90,16 +90,16 @@ func doGetRequest(url string, queryParams map[string]interface{}, headers map[st
90
90
return result , nil
91
91
}
92
92
93
- func doPostRequest (url string , params map [string ]interface {}, headers map [string ]interface {}) (map [string ]interface {}, error ) {
93
+ func doPostRequest (url string , params map [string ]interface {}, headers map [string ]interface {}) (map [string ]interface {}, int , error ) {
94
94
supertokens .LogDebugMessage (fmt .Sprintf ("POST request to %s, with form fields %v and headers %v" , url , params , headers ))
95
95
96
96
postBody , err := qs .Marshal (params )
97
97
if err != nil {
98
- return nil , err
98
+ return nil , - 1 , err
99
99
}
100
100
req , err := http .NewRequest ("POST" , url , bytes .NewBuffer ([]byte (postBody )))
101
101
if err != nil {
102
- return nil , err
102
+ return nil , - 1 , err
103
103
}
104
104
for key , value := range headers {
105
105
req .Header .Set (key , value .(string ))
@@ -110,28 +110,28 @@ func doPostRequest(url string, params map[string]interface{}, headers map[string
110
110
client := & http.Client {}
111
111
resp , err := client .Do (req )
112
112
if err != nil {
113
- return nil , err
113
+ return nil , resp . StatusCode , err
114
114
}
115
115
defer resp .Body .Close ()
116
116
117
117
body , err := ioutil .ReadAll (resp .Body )
118
118
if err != nil {
119
- return nil , err
119
+ return nil , resp . StatusCode , err
120
120
}
121
121
122
122
supertokens .LogDebugMessage (fmt .Sprintf ("Received response with status %d and body %s" , resp .StatusCode , string (body )))
123
123
124
124
var result map [string ]interface {}
125
125
err = json .Unmarshal (body , & result )
126
126
if err != nil {
127
- return nil , err
127
+ return nil , resp . StatusCode , err
128
128
}
129
129
130
130
if resp .StatusCode >= 300 {
131
- return nil , fmt .Errorf ("POST request to %s resulted in %d status with body %s" , url , resp .StatusCode , string (body ))
131
+ return nil , resp . StatusCode , fmt .Errorf ("POST request to %s resulted in %d status with body %s" , url , resp .StatusCode , string (body ))
132
132
}
133
133
134
- return result , nil
134
+ return result , resp . StatusCode , nil
135
135
}
136
136
137
137
// JWKS utils
0 commit comments