Skip to content

Commit 3d0d227

Browse files
committed
fix: PR comments
1 parent c124cca commit 3d0d227

File tree

3 files changed

+15
-33
lines changed

3 files changed

+15
-33
lines changed

recipe/session/testingUtils.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
package session
1717

1818
import (
19+
"net/http"
20+
1921
"github.com/supertokens/supertokens-golang/supertokens"
2022
"github.com/supertokens/supertokens-golang/test/unittesting"
2123
)
@@ -36,3 +38,15 @@ func AfterEach() {
3638
resetAll()
3739
unittesting.CleanST()
3840
}
41+
42+
type fakeRes struct{}
43+
44+
func (f fakeRes) Header() http.Header {
45+
return http.Header{}
46+
}
47+
48+
func (f fakeRes) Write(body []byte) (int, error) {
49+
return len(body), nil
50+
}
51+
52+
func (f fakeRes) WriteHeader(statusCode int) {}

recipe/session/utils.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -391,15 +391,3 @@ func getRequiredClaimValidators(
391391
}
392392
return globalClaimValidators, nil
393393
}
394-
395-
type fakeRes struct{}
396-
397-
func (f fakeRes) Header() http.Header {
398-
return http.Header{}
399-
}
400-
401-
func (f fakeRes) Write(body []byte) (int, error) {
402-
return len(body), nil
403-
}
404-
405-
func (f fakeRes) WriteHeader(statusCode int) {}

supertokens/utils.go

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -158,27 +158,7 @@ func Send200Response(res http.ResponseWriter, responseJson interface{}) error {
158158
}
159159

160160
func SendNon200ResponseWithMessage(res http.ResponseWriter, message string, statusCode int) error {
161-
dw := MakeDoneWriter(res)
162-
if !dw.IsDone() {
163-
if statusCode < 300 {
164-
return errors.New("calling sendNon200ResponseWithMessage with status code < 300")
165-
}
166-
167-
LogDebugMessage("Sending response to client with status code: " + strconv.Itoa(statusCode))
168-
169-
res.Header().Set("Content-Type", "application/json; charset=utf-8")
170-
res.WriteHeader(statusCode)
171-
response := map[string]interface{}{
172-
"message": message,
173-
}
174-
bytes, err := json.Marshal(response)
175-
if err != nil {
176-
return err
177-
} else {
178-
res.Write(bytes)
179-
}
180-
}
181-
return nil
161+
return SendNon200Response(res, statusCode, map[string]interface{}{"message": message})
182162
}
183163

184164
func SendNon200Response(res http.ResponseWriter, statusCode int, body map[string]interface{}) error {

0 commit comments

Comments
 (0)