aboutsummaryrefslogtreecommitdiffstats
path: root/modules/private/request.go
diff options
context:
space:
mode:
authoryp05327 <576951401@qq.com>2024-01-19 11:45:23 +0900
committerGitHub <noreply@github.com>2024-01-19 10:45:23 +0800
commitb60a7c3358cdeec3e0a731b68be33b6ba63a6563 (patch)
tree3211199f510d1f9ea2318bb596fab02262058014 /modules/private/request.go
parent4674aea25b54baf08594c54f061dee9e44190f02 (diff)
downloadgitea-b60a7c3358cdeec3e0a731b68be33b6ba63a6563.tar.gz
gitea-b60a7c3358cdeec3e0a731b68be33b6ba63a6563.zip
Return `responseText` instead of string in some functions (#28836)
Follow https://github.com/go-gitea/gitea/pull/28796#issuecomment-1891727591
Diffstat (limited to 'modules/private/request.go')
-rw-r--r--modules/private/request.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/modules/private/request.go b/modules/private/request.go
index 2bc43b972d..58cd261239 100644
--- a/modules/private/request.go
+++ b/modules/private/request.go
@@ -12,8 +12,8 @@ import (
"code.gitea.io/gitea/modules/json"
)
-// responseText is used to get the response as text, instead of parsing it as JSON.
-type responseText struct {
+// ResponseText is used to get the response as text, instead of parsing it as JSON.
+type ResponseText struct {
Text string
}
@@ -50,7 +50,7 @@ func (re responseError) Error() string {
// Caller should check the ResponseExtra.HasError() first to see whether the request fails.
//
// * If the "res" is a struct pointer, the response will be parsed as JSON
-// * If the "res" is responseText pointer, the response will be stored as text in it
+// * If the "res" is ResponseText pointer, the response will be stored as text in it
// * If the "res" is responseCallback pointer, the callback function should set the ResponseExtra fields accordingly
func requestJSONResp[T any](req *httplib.Request, res *T) (ret *T, extra ResponseExtra) {
resp, err := req.Response()
@@ -81,7 +81,7 @@ func requestJSONResp[T any](req *httplib.Request, res *T) (ret *T, extra Respons
// now, the StatusCode must be 2xx
var v any = res
- if respText, ok := v.(*responseText); ok {
+ if respText, ok := v.(*ResponseText); ok {
// get the whole response as a text string
bs, err := io.ReadAll(resp.Body)
if err != nil {
@@ -119,7 +119,7 @@ func requestJSONResp[T any](req *httplib.Request, res *T) (ret *T, extra Respons
// requestJSONClientMsg sends a request to the gitea server, server only responds text message status=200 with "success" body
// If the request succeeds (200), the argument clientSuccessMsg will be used as ResponseExtra.UserMsg.
func requestJSONClientMsg(req *httplib.Request, clientSuccessMsg string) ResponseExtra {
- _, extra := requestJSONResp(req, &responseText{})
+ _, extra := requestJSONResp(req, &ResponseText{})
if extra.HasError() {
return extra
}