@@ -12,8 +12,8 @@ import (
12
12
"code.gitea.io/gitea/modules/json"
13
13
)
14
14
15
- // responseText is used to get the response as text, instead of parsing it as JSON.
16
- type responseText struct {
15
+ // ResponseText is used to get the response as text, instead of parsing it as JSON.
16
+ type ResponseText struct {
17
17
Text string
18
18
}
19
19
@@ -50,7 +50,7 @@ func (re responseError) Error() string {
50
50
// Caller should check the ResponseExtra.HasError() first to see whether the request fails.
51
51
//
52
52
// * If the "res" is a struct pointer, the response will be parsed as JSON
53
- // * If the "res" is responseText pointer, the response will be stored as text in it
53
+ // * If the "res" is ResponseText pointer, the response will be stored as text in it
54
54
// * If the "res" is responseCallback pointer, the callback function should set the ResponseExtra fields accordingly
55
55
func requestJSONResp [T any ](req * httplib.Request , res * T ) (ret * T , extra ResponseExtra ) {
56
56
resp , err := req .Response ()
@@ -81,7 +81,7 @@ func requestJSONResp[T any](req *httplib.Request, res *T) (ret *T, extra Respons
81
81
82
82
// now, the StatusCode must be 2xx
83
83
var v any = res
84
- if respText , ok := v .(* responseText ); ok {
84
+ if respText , ok := v .(* ResponseText ); ok {
85
85
// get the whole response as a text string
86
86
bs , err := io .ReadAll (resp .Body )
87
87
if err != nil {
@@ -119,7 +119,7 @@ func requestJSONResp[T any](req *httplib.Request, res *T) (ret *T, extra Respons
119
119
// requestJSONClientMsg sends a request to the gitea server, server only responds text message status=200 with "success" body
120
120
// If the request succeeds (200), the argument clientSuccessMsg will be used as ResponseExtra.UserMsg.
121
121
func requestJSONClientMsg (req * httplib.Request , clientSuccessMsg string ) ResponseExtra {
122
- _ , extra := requestJSONResp (req , & responseText {})
122
+ _ , extra := requestJSONResp (req , & ResponseText {})
123
123
if extra .HasError () {
124
124
return extra
125
125
}
0 commit comments